home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 May / CMCD0504.ISO / Software / Freeware / Programare / dspack / DSPACK231.exe / {app} / src / DirectX9 / D3DX9.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2003-04-27  |  297.1 KB  |  7,973 lines

  1. {******************************************************************************}
  2. {*                                                                            *}
  3. {*  Copyright (C) Microsoft Corporation.  All Rights Reserved.                *}
  4. {*                                                                            *}
  5. {*  File:       d3dx9.h, d3dx9anim.h, d3dx9core.h, d3dx9effect.h,             *}
  6. {*              d3dx9math.h, d3dx9math.inl, d3dx9mesh.h, d3dx9shader.h,       *}
  7. {*              d3dx9shape.h, d3dx9tex.h                                      *}
  8. {*                                                                            *}
  9. {*  Content:    Direct3DX 9.0 headers                                         *}
  10. {*                                                                            *}
  11. {*  Direct3DX 9.0 Delphi adaptation by Alexey Barkovoy                        *}
  12. {*  E-Mail: clootie@reactor.ru                                                *}
  13. {*                                                                            *}
  14. {*  Modified: 27-Apr-2003                                                     *}
  15. {*                                                                            *}
  16. {*  Latest version can be downloaded from:                                    *}
  17. {*     http://clootie.narod.ru/delphi                                         *}
  18. {*                                                                            *}
  19. {*  This File contains only Direct3DX 9.0 Definitions.                        *}
  20. {*  If you want to use previous versions - use D3DX.pas and D3DX8.pas         *}
  21. {*                                                                            *}
  22. {******************************************************************************)
  23. {                                                                              }
  24. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI)        }
  25. {                                                                              }
  26. { The contents of this file are used with permission, subject to the Mozilla   }
  27. { Public License Version 1.1 (the "License"); you may not use this file except }
  28. { in compliance with the License. You may obtain a copy of the License at      }
  29. { http://www.mozilla.org/MPL/MPL-1.1.html                                      }
  30. {                                                                              }
  31. { Software distributed under the License is distributed on an "AS IS" basis,   }
  32. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  33. { the specific language governing rights and limitations under the License.    }
  34. {                                                                              }
  35. { Alternatively, the contents of this file may be used under the terms of the  }
  36. { GNU Lesser General Public License (the  "LGPL License"), in which case the   }
  37. { provisions of the LGPL License are applicable instead of those above.        }
  38. { If you wish to allow use of your version of this file only under the terms   }
  39. { of the LGPL License and not to allow others to use your version of this file }
  40. { under the MPL, indicate your decision by deleting  the provisions above and  }
  41. { replace  them with the notice and other provisions required by the LGPL      }
  42. { License.  If you do not delete the provisions above, a recipient may use     }
  43. { your version of this file under either the MPL or the LGPL License.          }
  44. {                                                                              }
  45. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  46. {                                                                              }
  47. {******************************************************************************}
  48.  
  49. // Original source contained in "D3DX9.par"
  50.  
  51. {$I DirectX.inc}
  52.  
  53. unit D3DX9;
  54.  
  55. interface
  56.  
  57. // Remove "dot" below to link with debug version of D3DX9
  58. // (only in JEDI or TMT pascal version)
  59. {.$DEFINE DEBUG}
  60.  
  61. // Remove "dot" below to link with separate DLL's (one DLL per part of D3DX9 API)
  62. // instead of monolithic "all-in-one" version of D3DX9
  63. {.$DEFINE D3DX_SEPARATE}
  64.  
  65. // Remove "dot" below to link with Tim Baumgarten D3D9.pas
  66. // note: it currently has bugged definition of D3DMATRIX (on 27-Apr-2003)
  67. {.$DEFINE DXG_COMPAT}
  68.  
  69. (*$HPPEMIT '#include "d3dx9.h"' *)
  70. (*$HPPEMIT '#include "dxfile.h"' *)
  71.  
  72. // Do not emit "hpp" files to C++Builder
  73. {$NOINCLUDE DXFile}
  74.  
  75. (*$HPPEMIT 'namespace D3dx9' *)
  76.  
  77. (*$HPPEMIT '{' *)
  78.  
  79. uses
  80.   Windows,
  81.   ActiveX,
  82.   SysUtils,
  83.   {$IFDEF DXG_COMPAT}D3D9{$ELSE}Direct3D9{$ENDIF},
  84.   DXFile;
  85.  
  86. const
  87.   //////////// DLL export definitions ///////////////////////////////////////
  88.   d3dx9dll ={$IFDEF DEBUG} 'd3dx9d.dll'{$ELSE} 'D3DX9ab.dll'{$ENDIF};
  89.   {$IFDEF DEBUG}{$UNDEF D3DX_SEPARATE}{$ENDIF}
  90.   d3dx9mathDLL   = {$IFDEF D3DX_SEPARATE}'d3dx9abMath.dll'{$ELSE}d3dx9dll{$ENDIF};
  91.   d3dx9coreDLL   = {$IFDEF D3DX_SEPARATE}'d3dx9abCore.dll'{$ELSE}d3dx9dll{$ENDIF};
  92.   d3dx9shaderDLL = {$IFDEF D3DX_SEPARATE}'d3dx9abShader.dll'{$ELSE}d3dx9dll{$ENDIF};
  93.   d3dx9effectDLL = {$IFDEF D3DX_SEPARATE}'d3dx9abEffect.dll'{$ELSE}d3dx9dll{$ENDIF};
  94.   d3dx9meshDLL   = {$IFDEF D3DX_SEPARATE}'d3dx9abMesh.dll'{$ELSE}d3dx9dll{$ENDIF};
  95.   d3dx9shapesDLL = {$IFDEF D3DX_SEPARATE}'d3dx9abShapes.dll'{$ELSE}d3dx9dll{$ENDIF};
  96.   d3dx9texDLL    = {$IFDEF D3DX_SEPARATE}'d3dx9abTex.dll'{$ELSE}d3dx9dll{$ENDIF};
  97.   d3dx9animDLL   = {$IFDEF D3DX_SEPARATE}'d3dx9abAnim.dll'{$ELSE}d3dx9dll{$ENDIF};
  98.  
  99.  
  100. {$IFNDEF COMPILER6_UP}
  101. type
  102.   PPointer = ^Pointer;
  103.   PPAnsiChar = ^PAnsiChar;
  104.  
  105. {$ENDIF}
  106. //////////////////////////////////////////////////////////////////////////////
  107. //
  108. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  109. //
  110. //  File:       d3dx9.h
  111. //  Content:    D3DX utility library
  112. //
  113. //////////////////////////////////////////////////////////////////////////////
  114.  
  115. const
  116.   // #define D3DX_DEFAULT ULONG_MAX
  117.   // #define D3DX_DEFAULT            ((UINT) -1)
  118.   D3DX_DEFAULT          = Cardinal(-1);
  119.   {$EXTERNALSYM D3DX_DEFAULT}
  120.   // #define D3DX_DEFAULT_NONPOW2    ((UINT) -2)
  121.   D3DX_DEFAULT_NONPOW2  = Cardinal(-2);
  122.   {$EXTERNALSYM D3DX_DEFAULT_NONPOW2}
  123.  
  124. var
  125.   // #define D3DX_DEFAULT_FLOAT FLT_MAX
  126.   // Forced to define as 'var' cos pascal compiler treats all consts as Double
  127.   D3DX_DEFAULT_FLOAT: Single = 3.402823466e+38;  // max single value
  128.   {$EXTERNALSYM D3DX_DEFAULT_FLOAT}
  129.  
  130. type
  131.   _D3DXERR = HResult;
  132.   {$EXTERNALSYM _D3DXERR}
  133.  
  134. {$IFDEF DXG_COMPAT}
  135. const
  136.   MAKE_D3DHRESULT_R = MAKE_D3DHRESULT;
  137. {$ENDIF}
  138.  
  139. const
  140.   D3DXERR_CANNOTMODIFYINDEXBUFFER       = HResult(MAKE_D3DHRESULT_R or 2900);
  141.   {$EXTERNALSYM D3DXERR_CANNOTMODIFYINDEXBUFFER}
  142.   D3DXERR_INVALIDMESH                   = HResult(MAKE_D3DHRESULT_R or 2901);
  143.   {$EXTERNALSYM D3DXERR_INVALIDMESH}
  144.   D3DXERR_CANNOTATTRSORT                = HResult(MAKE_D3DHRESULT_R or 2902);
  145.   {$EXTERNALSYM D3DXERR_CANNOTATTRSORT}
  146.   D3DXERR_SKINNINGNOTSUPPORTED          = HResult(MAKE_D3DHRESULT_R or 2903);
  147.   {$EXTERNALSYM D3DXERR_SKINNINGNOTSUPPORTED}
  148.   D3DXERR_TOOMANYINFLUENCES             = HResult(MAKE_D3DHRESULT_R or 2904);
  149.   {$EXTERNALSYM D3DXERR_TOOMANYINFLUENCES}
  150.   D3DXERR_INVALIDDATA                   = HResult(MAKE_D3DHRESULT_R or 2905);
  151.   {$EXTERNALSYM D3DXERR_INVALIDDATA}
  152.   D3DXERR_LOADEDMESHASNODATA            = HResult(MAKE_D3DHRESULT_R or 2906);
  153.   {$EXTERNALSYM D3DXERR_LOADEDMESHASNODATA}
  154.   D3DXERR_DUPLICATENAMEDFRAGMENT        = HResult(MAKE_D3DHRESULT_R or 2907);
  155.   {$EXTERNALSYM D3DXERR_DUPLICATENAMEDFRAGMENT}
  156.  
  157.  
  158.  
  159.  
  160. //////////////////////////////////////////////////////////////////////////////
  161. //
  162. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  163. //
  164. //  File:       d3dx9math.h
  165. //  Content:    D3DX math types and functions
  166. //
  167. //////////////////////////////////////////////////////////////////////////////
  168.  
  169. //===========================================================================
  170. //
  171. // General purpose utilities
  172. //
  173. //===========================================================================
  174. const
  175.   D3DX_PI: Single       = 3.141592654;
  176.   {$EXTERNALSYM D3DX_PI}
  177.   D3DX_1BYPI: Single    = 0.318309886;
  178.   {$EXTERNALSYM D3DX_1BYPI}
  179.  
  180. //#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f))
  181. function D3DXToRadian(Degree: Single): Single;
  182. {$EXTERNALSYM D3DXToRadian}
  183. //#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI))
  184. function D3DXToDegree(Radian: Single): Single;
  185. {$EXTERNALSYM D3DXToDegree}
  186.  
  187.  
  188.  
  189. //===========================================================================
  190. //
  191. // 16 bit floating point numbers
  192. //
  193. //===========================================================================
  194.  
  195. const
  196.   D3DX_16F_DIG          = 3;               // # of decimal digits of precision
  197.   {$EXTERNALSYM D3DX_16F_DIG}
  198.   D3DX_16F_EPSILON      = 4.8875809e-4;    // smallest such that 1.0 + epsilon <> 1.0
  199.   {$EXTERNALSYM D3DX_16F_EPSILON}
  200.   D3DX_16F_MANT_DIG     = 11;              // # of bits in mantissa
  201.   {$EXTERNALSYM D3DX_16F_MANT_DIG}
  202.   D3DX_16F_MAX          = 6.550400e+004;   // max value
  203.   {$EXTERNALSYM D3DX_16F_MAX}
  204.   D3DX_16F_MAX_10_EXP   = 4;               // max decimal exponent
  205.   {$EXTERNALSYM D3DX_16F_MAX_10_EXP}
  206.   D3DX_16F_MAX_EXP      = 15;              // max binary exponent
  207.   {$EXTERNALSYM D3DX_16F_MAX_EXP}
  208.   D3DX_16F_MIN          = 6.1035156e-5;    // min positive value
  209.   {$EXTERNALSYM D3DX_16F_MIN}
  210.   D3DX_16F_MIN_10_EXP   = -4;              // min decimal exponent
  211.   {$EXTERNALSYM D3DX_16F_MIN_10_EXP}
  212.   D3DX_16F_MIN_EXP      = -12;             // min binary exponent
  213.   {$EXTERNALSYM D3DX_16F_MIN_EXP}
  214.   D3DX_16F_RADIX        = 2;               // exponent radix
  215.   {$EXTERNALSYM D3DX_16F_RADIX}
  216.   D3DX_16F_ROUNDS       = 1;               // addition rounding: near
  217.   {$EXTERNALSYM D3DX_16F_ROUNDS}
  218.  
  219.  
  220. type
  221.   (*$HPPEMIT 'typedef D3DXFLOAT16       TD3DXFloat16;' *)
  222.   (*$HPPEMIT 'typedef D3DXFLOAT16      *PD3DXFloat16;' *)
  223.   PD3DXFloat16 = ^TD3DXFloat16;
  224.   {$EXTERNALSYM PD3DXFloat16}
  225.   TD3DXFloat16 = packed record
  226.     value: Word;
  227.   end;
  228.   {$NODEFINE TD3DXFloat16}
  229.  
  230. // Some pascal equalents of C++ class functions & operators
  231. const D3DXFloat16Zero: TD3DXFloat16 = (value:0); // 0
  232. function D3DXFloat16(value: Single): TD3DXFloat16;
  233. function D3DXFloat16Equal(const v1, v2: TD3DXFloat16): Boolean;
  234. function D3DXFloat16ToFloat(value: TD3DXFloat16): Single;
  235.  
  236.  
  237.  
  238. //===========================================================================
  239. //
  240. // Vectors
  241. //
  242. //===========================================================================
  243.  
  244.  
  245. //--------------------------
  246. // 2D Vector
  247. //--------------------------
  248. type
  249.   (*$HPPEMIT 'typedef D3DXVECTOR2       TD3DXVector2;' *)
  250.   (*$HPPEMIT 'typedef D3DXVECTOR2      *PD3DXVector2;' *)
  251.   PD3DXVector2 = ^TD3DXVector2;
  252.   {$EXTERNALSYM PD3DXVector2}
  253.   TD3DXVector2 = packed record
  254.     x, y: Single;
  255.   end;
  256.   {$NODEFINE TD3DXVector2}
  257.  
  258. // Some pascal equalents of C++ class functions & operators
  259. const D3DXVector2Zero: TD3DXVector2 = (x:0; y:0);  // (0,0)
  260. function D3DXVector2(_x, _y: Single): TD3DXVector2;
  261. function D3DXVector2Equal(const v1, v2: TD3DXVector2): Boolean;
  262.  
  263.  
  264.  
  265. //--------------------------
  266. // 2D Vector (16 bit)
  267. //--------------------------
  268. type
  269.   (*$HPPEMIT 'typedef D3DXVECTOR2_16F       TD3DXVector2_16F;' *)
  270.   (*$HPPEMIT 'typedef D3DXVECTOR2_16F      *PD3DXVector2_16F;' *)
  271.   PD3DXVector2_16F = ^TD3DXVector2_16F;
  272.   {$EXTERNALSYM PD3DXVector2_16F}
  273.   TD3DXVector2_16F = packed record
  274.     x, y: TD3DXFloat16;
  275.   end;
  276.   {$NODEFINE TD3DXVector2_16F}
  277.  
  278. // Some pascal equalents of C++ class functions & operators
  279. const D3DXVector2_16fZero: TD3DXVector2_16F = (x:(value:0); y:(value:0));  // (0,0)
  280. function D3DXVector2_16F(_x, _y: TD3DXFloat16): TD3DXVector2_16F;
  281. function D3DXVector2_16fEqual(const v1, v2: TD3DXVector2_16F): Boolean;
  282. function D3DXVector2_16fFromVector2(const v: TD3DXVector2): TD3DXVector2_16f;
  283. function D3DXVector2FromVector2_16f(const v: TD3DXVector2_16f): TD3DXVector2;
  284.  
  285.  
  286.  
  287. //--------------------------
  288. // 3D Vector
  289. //--------------------------
  290. type
  291.   (*$HPPEMIT 'typedef D3DXVECTOR3       TD3DXVector3;' *)
  292.   (*$HPPEMIT 'typedef D3DXVECTOR3      *PD3DXVector3;' *)
  293.   PD3DXVector3 = ^TD3DXVector3;
  294.   {$EXTERNALSYM PD3DXVector3}
  295.   TD3DXVector3 = TD3DVector;
  296.   {$NODEFINE TD3DXVector3}
  297.  
  298. // Some pascal equalents of C++ class functions & operators
  299. const D3DXVector3Zero: TD3DXVector3 = (x:0; y:0; z:0);  // (0,0,0)
  300. function D3DXVector3(_x, _y, _z: Single): TD3DXVector3;
  301. function D3DXVector3Equal(const v1, v2: TD3DXVector3): Boolean;
  302.  
  303.  
  304.  
  305. //--------------------------
  306. // 3D Vector (16 bit)
  307. //--------------------------
  308. type
  309.   (*$HPPEMIT 'typedef D3DXVECTOR3_16F       TD3DXVector3_16F;' *)
  310.   (*$HPPEMIT 'typedef D3DXVECTOR3_16F      *PD3DXVector3_16F;' *)
  311.   PD3DXVector3_16F = ^TD3DXVector3_16F;
  312.   {$EXTERNALSYM PD3DXVector3}
  313.   TD3DXVector3_16F = packed record
  314.     x, y, z: TD3DXFloat16;
  315.   end;
  316.   {$NODEFINE TD3DXVector3_16F}
  317.  
  318. // Some pascal equalents of C++ class functions & operators
  319. const D3DXVector3_16fZero: TD3DXVector3_16F = (x:(value:0); y:(value:0); z:(value:0));  // (0,0,0)
  320. function D3DXVector3_16F(_x, _y, _z: TD3DXFloat16): TD3DXVector3_16F;
  321. function D3DXVector3_16fEqual(const v1, v2: TD3DXVector3_16F): Boolean;
  322. function D3DXVector3_16fFromVector3(const v: TD3DXVector3): TD3DXVector3_16f;
  323. function D3DXVector3FromVector3_16f(const v: TD3DXVector3_16f): TD3DXVector3;
  324.  
  325.  
  326.  
  327. //--------------------------
  328. // 4D Vector
  329. //--------------------------
  330. type
  331.   (*$HPPEMIT 'typedef D3DXVECTOR4       TD3DXVector4;' *)
  332.   (*$HPPEMIT 'typedef D3DXVECTOR4      *PD3DXVector4;' *)
  333.   PD3DXVector4 = ^TD3DXVector4;
  334.   {$EXTERNALSYM PD3DXVector4}
  335.   TD3DXVector4 = packed record
  336.     x, y, z, w: Single;
  337.   end;
  338.   {$NODEFINE TD3DXVector4}
  339.  
  340. // Some pascal equalents of C++ class functions & operators
  341. const D3DXVector4Zero: TD3DXVector4 = (x:0; y:0; z:0; w:0);  // (0,0,0,0)
  342. function D3DXVector4(_x, _y, _z, _w: Single): TD3DXVector4;
  343. function D3DXVector4Equal(const v1, v2: TD3DXVector4): Boolean;
  344.  
  345.  
  346.  
  347. //--------------------------
  348. // 4D Vector (16 bit)
  349. //--------------------------
  350. type
  351.   (*$HPPEMIT 'typedef D3DXVECTOR4_16F       TD3DXVector4_16F;' *)
  352.   (*$HPPEMIT 'typedef D3DXVECTOR4_16F      *PD3DXVector4_16F;' *)
  353.   PD3DXVector4_16F = ^TD3DXVector4_16F;
  354.   {$EXTERNALSYM PD3DXVector4_16F}
  355.   TD3DXVector4_16F = packed record
  356.     x, y, z, w: TD3DXFloat16;
  357.   end;
  358.   {$NODEFINE TD3DXVector4_16F}
  359.  
  360. // Some pascal equalents of C++ class functions & operators
  361. const D3DXVector4_16fZero: TD3DXVector4_16F = (x:(value:0); y:(value:0); z:(value:0); w:(value:0));  // (0,0,0,0)
  362. function D3DXVector4_16F(_x, _y, _z, _w: TD3DXFloat16): TD3DXVector4_16F;
  363. function D3DXVector4_16fEqual(const v1, v2: TD3DXVector4_16F): Boolean;
  364. function D3DXVector4_16fFromVector4(const v: TD3DXVector4): TD3DXVector4_16f;
  365. function D3DXVector4FromVector4_16f(const v: TD3DXVector4_16f): TD3DXVector4;
  366.  
  367.  
  368.  
  369. //===========================================================================
  370. //
  371. // Matrices
  372. //
  373. //===========================================================================
  374. type
  375.   (*$HPPEMIT 'typedef D3DXMATRIX        TD3DXMatrix;' *)
  376.   (*$HPPEMIT 'typedef D3DXMATRIX       *PD3DXMatrix;' *)
  377.   (*$HPPEMIT 'typedef D3DXMATRIX      **PPD3DXMatrix;' *)
  378.   PPD3DXMatrix = ^PD3DXMatrix;
  379.   PD3DXMatrix = ^TD3DXMatrix;
  380.   {$EXTERNALSYM PD3DXMatrix}
  381.   TD3DXMatrix = TD3DMatrix;
  382.   {$NODEFINE TD3DXMatrix}
  383.  
  384. // Some pascal equalents of C++ class functions & operators
  385. function D3DXMatrix(
  386.   _m00, _m01, _m02, _m03,
  387.   _m10, _m11, _m12, _m13,
  388.   _m20, _m21, _m22, _m23,
  389.   _m30, _m31, _m32, _m33: Single): TD3DXMatrix;
  390. function D3DXMatrixAdd(out mOut: TD3DXMatrix; const m1, m2: TD3DXMatrix): PD3DXMatrix;
  391. function D3DXMatrixSubtract(out mOut: TD3DXMatrix; const m1, m2: TD3DXMatrix): PD3DXMatrix;
  392. function D3DXMatrixMul(out mOut: TD3DXMatrix; const m: TD3DXMatrix; MulBy: Single): PD3DXMatrix;
  393. function D3DXMatrixEqual(const m1, m2: TD3DXMatrix): Boolean;
  394.  
  395.  
  396. //---------------------------------------------------------------------------
  397. // Aligned Matrices
  398. //
  399. // This class helps keep matrices 16-byte aligned as preferred by P4 cpus.
  400. // It aligns matrices on the stack and on the heap or in global scope.
  401. // It does this using __declspec(align(16)) which works on VC7 and on VC 6
  402. // with the processor pack. Unfortunately there is no way to detect the
  403. // latter so this is turned on only on VC7. On other compilers this is the
  404. // the same as D3DXMATRIX.
  405. //
  406. // Using this class on a compiler that does not actually do the alignment
  407. // can be dangerous since it will not expose bugs that ignore alignment.
  408. // E.g if an object of this class in inside a struct or class, and some code
  409. // memcopys data in it assuming tight packing. This could break on a compiler
  410. // that eventually start aligning the matrix.
  411. //---------------------------------------------------------------------------
  412.  
  413. // Translator comments: None of current pascal compilers can even align data
  414. // inside records to 16 byte boundary, so we just leave aligned matrix
  415. // declaration equal to standart matrix
  416. type
  417.   PD3DXMatrixA16 = ^TD3DXMatrixA16;
  418.   TD3DXMatrixA16 = TD3DXMatrix;
  419.  
  420.  
  421. //===========================================================================
  422. //
  423. //    Quaternions
  424. //
  425. //===========================================================================
  426. type
  427.   (*$HPPEMIT 'typedef D3DXQUATERNION TD3DXQuaternion;' *)
  428.   PD3DXQuaternion = ^TD3DXQuaternion;
  429.   TD3DXQuaternion = packed record
  430.     x, y, z, w: Single;
  431.   end;
  432.   {$NODEFINE TD3DXQuaternion}
  433.  
  434. // Some pascal equalents of C++ class functions & operators
  435. function D3DXQuaternion(_x, _y, _z, _w: Single): TD3DXQuaternion;
  436. function D3DXQuaternionAdd(const q1, q2: TD3DXQuaternion): TD3DXQuaternion;
  437. function D3DXQuaternionSubtract(const q1, q2: TD3DXQuaternion): TD3DXQuaternion;
  438. function D3DXQuaternionEqual(const q1, q2: TD3DXQuaternion): Boolean;
  439. function D3DXQuaternionScale(out qOut: TD3DXQuaternion; const q: TD3DXQuaternion;
  440.   s: Single): PD3DXQuaternion;
  441.  
  442.  
  443.  
  444. //===========================================================================
  445. //
  446. // Planes
  447. //
  448. //===========================================================================
  449. type
  450.   (*$HPPEMIT 'typedef D3DXPLANE TD3DXPlane;' *)
  451.   PD3DXPlane = ^TD3DXPlane;
  452.   TD3DXPlane = packed record
  453.     a, b, c, d: Single;
  454.   end;
  455.   {$NODEFINE TD3DXPlane}
  456.  
  457. // Some pascal equalents of C++ class functions & operators
  458. const D3DXPlaneZero: TD3DXPlane = (a:0; b:0; c:0; d:0);  // (0,0,0,0)
  459. function D3DXPlane(_a, _b, _c, _d: Single): TD3DXPlane;
  460. function D3DXPlaneEqual(const p1, p2: TD3DXPlane): Boolean;
  461.  
  462.  
  463. //===========================================================================
  464. //
  465. // Colors
  466. //
  467. //===========================================================================
  468. type
  469.   (*$HPPEMIT 'typedef D3DXCOLOR TD3DXColor;' *)
  470.   (*$HPPEMIT 'typedef D3DXCOLOR *PD3DXColor;' *)
  471.   PD3DXColor = PD3DColorValue;
  472.   {$EXTERNALSYM PD3DXColor}
  473.   TD3DXColor = TD3DColorValue;
  474.   {$EXTERNALSYM TD3DXColor}
  475.  
  476. function D3DXColor(_r, _g, _b, _a: Single): TD3DXColor;
  477. function D3DXColorToDWord(c: TD3DXColor): DWord;
  478. function D3DXColorFromDWord(c: DWord): TD3DXColor;
  479. function D3DXColorEqual(const c1, c2: TD3DXColor): Boolean;
  480.  
  481.  
  482. //===========================================================================
  483. //
  484. // D3DX math functions:
  485. //
  486. // NOTE:
  487. //  * All these functions can take the same object as in and out parameters.
  488. //
  489. //  * Out parameters are typically also returned as return values, so that
  490. //    the output of one function may be used as a parameter to another.
  491. //
  492. //===========================================================================
  493.  
  494. //--------------------------
  495. // Float16
  496. //--------------------------
  497.  
  498. // non-inline
  499.  
  500. // Converts an array 32-bit floats to 16-bit floats
  501. function D3DXFloat32To16Array(pOut: PD3DXFloat16; pIn: PSingle; n: LongWord): PD3DXFloat16; stdcall; external d3dx9mathDLL;
  502. {$EXTERNALSYM D3DXFloat32To16Array}
  503.  
  504. // Converts an array 16-bit floats to 32-bit floats
  505. function D3DXFloat16To32Array(pOut: PSingle; pIn: PD3DXFloat16; n: LongWord): PSingle; stdcall; external d3dx9mathDLL;
  506. {$EXTERNALSYM D3DXFloat16To32Array}
  507.  
  508.  
  509. //--------------------------
  510. // 2D Vector
  511. //--------------------------
  512.  
  513. // inline
  514.  
  515. function D3DXVec2Length(const v: TD3DXVector2): Single;
  516. {$EXTERNALSYM D3DXVec2Length}
  517.  
  518. function D3DXVec2LengthSq(const v: TD3DXVector2): Single;
  519. {$EXTERNALSYM D3DXVec2LengthSq}
  520.  
  521. function D3DXVec2Dot(const v1, v2: TD3DXVector2): Single;
  522. {$EXTERNALSYM D3DXVec2Dot}
  523.  
  524. // Z component of ((x1,y1,0) cross (x2,y2,0))
  525. function D3DXVec2CCW(const v1, v2: TD3DXVector2): Single;
  526. {$EXTERNALSYM D3DXVec2CCW}
  527.  
  528. function D3DXVec2Add(const v1, v2: TD3DXVector2): TD3DXVector2;
  529. {$EXTERNALSYM D3DXVec2Add}
  530.  
  531. function D3DXVec2Subtract(const v1, v2: TD3DXVector2): TD3DXVector2;
  532. {$EXTERNALSYM D3DXVec2Subtract}
  533.  
  534. // Minimize each component.  x = min(x1, x2), y = min(y1, y2)
  535. function D3DXVec2Minimize(out vOut: TD3DXVector2; const v1, v2: TD3DXVector2): PD3DXVector2;
  536. {$EXTERNALSYM D3DXVec2Minimize}
  537.  
  538. // Maximize each component.  x = max(x1, x2), y = max(y1, y2)
  539. function D3DXVec2Maximize(out vOut: TD3DXVector2; const v1, v2: TD3DXVector2): PD3DXVector2;
  540. {$EXTERNALSYM D3DXVec2Maximize}
  541.  
  542. function D3DXVec2Scale(out vOut: TD3DXVector2; const v: TD3DXVector2; s: Single): PD3DXVector2;
  543. {$EXTERNALSYM D3DXVec2Scale}
  544.  
  545. // Linear interpolation. V1 + s(V2-V1)
  546. function D3DXVec2Lerp(out vOut: TD3DXVector2; const v1, v2: TD3DXVector2; s: Single): PD3DXVector2;
  547. {$EXTERNALSYM D3DXVec2Lerp}
  548.  
  549. // non-inline
  550. function D3DXVec2Normalize(out vOut: TD3DXVector2; const v: TD3DXVector2): PD3DXVector2; stdcall; external d3dx9mathDLL;
  551. {$EXTERNALSYM D3DXVec2Normalize}
  552.  
  553. // Hermite interpolation between position V1, tangent T1 (when s == 0)
  554. // and position V2, tangent T2 (when s == 1).
  555. function D3DXVec2Hermite(out vOut: TD3DXVector2;
  556.    const v1, t1, v2, t2: TD3DXVector2; s: Single): PD3DXVector2; stdcall; external d3dx9mathDLL;
  557. {$EXTERNALSYM D3DXVec2Hermite}
  558.  
  559. // CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1)
  560. function D3DXVec2CatmullRom(out vOut: TD3DXVector2;
  561.    const v0, v1, v2: TD3DXVector2; s: Single): PD3DXVector2; stdcall; external d3dx9mathDLL;
  562. {$EXTERNALSYM D3DXVec2CatmullRom}
  563.  
  564. // Barycentric coordinates.  V1 + f(V2-V1) + g(V3-V1)
  565. function D3DXVec2BaryCentric(out vOut: TD3DXVector2;
  566.    const v1, v2, v3: TD3DXVector2; f, g: Single): PD3DXVector2; stdcall; external d3dx9mathDLL;
  567. {$EXTERNALSYM D3DXVec2BaryCentric}
  568.  
  569. // Transform (x, y, 0, 1) by matrix.
  570. function D3DXVec2Transform(out vOut: TD3DXVector4;
  571.   const v: TD3DXVector2; const m: TD3DXMatrix): PD3DXVector4; stdcall; external d3dx9mathDLL;
  572. {$EXTERNALSYM D3DXVec2Transform}
  573.  
  574. // Transform (x, y, 0, 1) by matrix, project result back into w=1.
  575. function D3DXVec2TransformCoord(out vOut: TD3DXVector2;
  576.   const v: TD3DXVector2; const m: TD3DXMatrix): PD3DXVector2; stdcall; external d3dx9mathDLL;
  577. {$EXTERNALSYM D3DXVec2TransformCoord}
  578.  
  579. // Transform (x, y, 0, 0) by matrix.
  580. function D3DXVec2TransformNormal(out vOut: TD3DXVector2;
  581.   const v: TD3DXVector2; const m: TD3DXMatrix): PD3DXVector2; stdcall; external d3dx9mathDLL;
  582. {$EXTERNALSYM D3DXVec2TransformNormal}
  583.  
  584.  
  585. // Transform Array (x, y, 0, 1) by matrix.
  586. function D3DXVec2TransformArray(pOut: PD3DXVector4; OutStride: LongWord;
  587.   pV: PD3DXVector2; VStride: LongWord; const m: TD3DXMatrix; n: LongWord): PD3DXVector4; stdcall; external d3dx9mathDLL;
  588. {$EXTERNALSYM D3DXVec2TransformArray}
  589.  
  590. // Transform Array (x, y, 0, 1) by matrix, project result back into w=1.
  591. function D3DXVec2TransformCoordArray(pOut: PD3DXVector2; OutStride: LongWord;
  592.   pV: PD3DXVector2; VStride: LongWord; const m: TD3DXMatrix; n: LongWord): PD3DXVector2; stdcall; external d3dx9mathDLL;
  593. {$EXTERNALSYM D3DXVec2TransformCoordArray}
  594.  
  595. // Transform Array (x, y, 0, 0) by matrix.
  596. function D3DXVec2TransformNormalArray(pOut: PD3DXVector2; OutStride: LongWord;
  597.   pV: PD3DXVector2; VStride: LongWord; const m: TD3DXMatrix; n: LongWord): PD3DXVector2; stdcall; external d3dx9mathDLL;
  598. {$EXTERNALSYM D3DXVec2TransformNormalArray}
  599.  
  600.  
  601. //--------------------------
  602. // 3D Vector
  603. //--------------------------
  604.  
  605. // inline
  606.  
  607. function D3DXVec3Length(const v: TD3DXVector3): Single;
  608. {$EXTERNALSYM D3DXVec3Length}
  609.  
  610. function D3DXVec3LengthSq(const v: TD3DXVector3): Single;
  611. {$EXTERNALSYM D3DXVec3LengthSq}
  612.  
  613. function D3DXVec3Dot(const v1, v2: TD3DXVector3): Single;
  614. {$EXTERNALSYM D3DXVec3Dot}
  615.  
  616. function D3DXVec3Cross(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  617. {$EXTERNALSYM D3DXVec3Cross}
  618.  
  619. function D3DXVec3Add(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  620. {$EXTERNALSYM D3DXVec3Add}
  621.  
  622. function D3DXVec3Subtract(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  623. {$EXTERNALSYM D3DXVec3Subtract}
  624.  
  625. // Minimize each component.  x = min(x1, x2), y = min(y1, y2), ...
  626. function D3DXVec3Minimize(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  627. {$EXTERNALSYM D3DXVec3Minimize}
  628.  
  629. // Maximize each component.  x = max(x1, x2), y = max(y1, y2), ...
  630. function D3DXVec3Maximize(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  631. {$EXTERNALSYM D3DXVec3Maximize}
  632.  
  633. function D3DXVec3Scale(out vOut: TD3DXVector3; const v: TD3DXVector3; s: Single): PD3DXVector3;
  634. {$EXTERNALSYM D3DXVec3Scale}
  635.  
  636. // Linear interpolation. V1 + s(V2-V1)
  637. function D3DXVec3Lerp(out vOut: TD3DXVector3;
  638.   const v1, v2: TD3DXVector3; s: Single): PD3DXVector3;
  639. {$EXTERNALSYM D3DXVec3Lerp}
  640.  
  641. // non-inline
  642.  
  643. function D3DXVec3Normalize(out vOut: TD3DXVector3;
  644.    const v: TD3DXVector3): PD3DXVector3; stdcall; external d3dx9mathDLL;
  645. {$EXTERNALSYM D3DXVec3Normalize}
  646.  
  647. // Hermite interpolation between position V1, tangent T1 (when s == 0)
  648. // and position V2, tangent T2 (when s == 1).
  649. function D3DXVec3Hermite(out vOut: TD3DXVector3;
  650.    const v1, t1, v2, t2: TD3DXVector3; s: Single): PD3DXVector3; stdcall; external d3dx9mathDLL;
  651. {$EXTERNALSYM D3DXVec3Hermite}
  652.  
  653. // CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1)
  654. function D3DXVec3CatmullRom(out vOut: TD3DXVector3;
  655.    const v1, v2, v3: TD3DXVector3; s: Single): PD3DXVector3; stdcall; external d3dx9mathDLL;
  656. {$EXTERNALSYM D3DXVec3CatmullRom}
  657.  
  658. // Barycentric coordinates.  V1 + f(V2-V1) + g(V3-V1)
  659. function D3DXVec3BaryCentric(out vOut: TD3DXVector3;
  660.    const v1, v2, v3: TD3DXVector3; f, g: Single): PD3DXVector3; stdcall; external d3dx9mathDLL;
  661. {$EXTERNALSYM D3DXVec3BaryCentric}
  662.  
  663. // Transform (x, y, z, 1) by matrix.
  664. function D3DXVec3Transform(out vOut: TD3DXVector4;
  665.   const v: TD3DXVector3; const m: TD3DXMatrix): PD3DXVector4; stdcall; external d3dx9mathDLL;
  666. {$EXTERNALSYM D3DXVec3Transform}
  667.  
  668. // Transform (x, y, z, 1) by matrix, project result back into w=1.
  669. function D3DXVec3TransformCoord(out vOut: TD3DXVector3;
  670.   const v: TD3DXVector3; const m: TD3DXMatrix): PD3DXVector3; stdcall; external d3dx9mathDLL;
  671. {$EXTERNALSYM D3DXVec3TransformCoord}
  672.  
  673. // Transform (x, y, z, 0) by matrix.  If you transforming a normal by a
  674. // non-affine matrix, the matrix you pass to this function should be the
  675. // transpose of the inverse of the matrix you would use to transform a coord.
  676. function D3DXVec3TransformNormal(out vOut: TD3DXVector3;
  677.   const v: TD3DXVector3; const m: TD3DXMatrix): PD3DXVector3; stdcall; external d3dx9mathDLL;
  678. {$EXTERNALSYM D3DXVec3TransformNormal}
  679.  
  680.  
  681. // Transform Array (x, y, z, 1) by matrix.
  682. function D3DXVec3TransformArray(pOut: PD3DXVector4; OutStride: LongWord;
  683.   pV: PD3DXVector3; VStride: LongWord; const m: TD3DXMatrix; n: LongWord): PD3DXVector4; stdcall; external d3dx9mathDLL;
  684. {$EXTERNALSYM D3DXVec3TransformArray}
  685.  
  686. // Transform Array (x, y, z, 1) by matrix, project result back into w=1.
  687. function D3DXVec3TransformCoordArray(pOut: PD3DXVector3; OutStride: LongWord;
  688.   pV: PD3DXVector3; VStride: LongWord; const m: TD3DXMatrix; n: LongWord): PD3DXVector3; stdcall; external d3dx9mathDLL;
  689. {$EXTERNALSYM D3DXVec3TransformCoordArray}
  690.  
  691. // Transform (x, y, z, 0) by matrix.  If you transforming a normal by a
  692. // non-affine matrix, the matrix you pass to this function should be the
  693. // transpose of the inverse of the matrix you would use to transform a coord.
  694. function D3DXVec3TransformNormalArray(pOut: PD3DXVector3; OutStride: LongWord;
  695.   pV: PD3DXVector3; VStride: LongWord; const m: TD3DXMatrix; n: LongWord): PD3DXVector3; stdcall; external d3dx9mathDLL;
  696. {$EXTERNALSYM D3DXVec3TransformNormalArray}
  697.  
  698. // Project vector from object space into screen space
  699. function D3DXVec3Project(out vOut: TD3DXVector3;
  700.   const v: TD3DXVector3; const pViewport: TD3DViewport9;
  701.   const pProjection, pView, pWorld: TD3DXMatrix): PD3DXVector3; stdcall; external d3dx9mathDLL;
  702. {$EXTERNALSYM D3DXVec3Project}
  703.  
  704. // Project vector from screen space into object space
  705. function D3DXVec3Unproject(out vOut: TD3DXVector3;
  706.   const v: TD3DXVector3; const pViewport: TD3DViewport9;
  707.   const pProjection, pView, pWorld: TD3DXMatrix): PD3DXVector3; stdcall; external d3dx9mathDLL;
  708. {$EXTERNALSYM D3DXVec3Unproject}
  709.  
  710. // Project vector Array from object space into screen space
  711. function D3DXVec3ProjectArray(pOut: PD3DXVector3; OutStride: LongWord;
  712.   pV: PD3DXVector3; VStride: LongWord; const pViewport: TD3DViewport9;
  713.   const pProjection, pView, pWorld: TD3DXMatrix; n: LongWord): PD3DXVector3; stdcall; external d3dx9mathDLL;
  714. {$EXTERNALSYM D3DXVec3ProjectArray}
  715.  
  716. // Project vector Array from screen space into object space
  717. function D3DXVec3UnprojectArray(pOut: PD3DXVector3; OutStride: LongWord;
  718.   pV: PD3DXVector3; VStride: LongWord; const pViewport: TD3DViewport9;
  719.   const pProjection, pView, pWorld: TD3DXMatrix; n: LongWord): PD3DXVector3; stdcall; external d3dx9mathDLL;
  720. {$EXTERNALSYM D3DXVec3UnprojectArray}
  721.  
  722.  
  723. //--------------------------
  724. // 4D Vector
  725. //--------------------------
  726.  
  727. // inline
  728.  
  729. function D3DXVec4Length(const v: TD3DXVector4): Single;
  730. {$EXTERNALSYM D3DXVec4Length}
  731.  
  732. function D3DXVec4LengthSq(const v: TD3DXVector4): Single;
  733. {$EXTERNALSYM D3DXVec4LengthSq}
  734.  
  735. function D3DXVec4Dot(const v1, v2: TD3DXVector4): Single;
  736. {$EXTERNALSYM D3DXVec4Dot}
  737.  
  738. function D3DXVec4Add(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  739. {$EXTERNALSYM D3DXVec4Add}
  740.  
  741. function D3DXVec4Subtract(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  742. {$EXTERNALSYM D3DXVec4Subtract}
  743.  
  744. // Minimize each component.  x = min(x1, x2), y = min(y1, y2), ...
  745. function D3DXVec4Minimize(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  746. {$EXTERNALSYM D3DXVec4Minimize}
  747.  
  748. // Maximize each component.  x = max(x1, x2), y = max(y1, y2), ...
  749. function D3DXVec4Maximize(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  750. {$EXTERNALSYM D3DXVec4Maximize}
  751.  
  752. function D3DXVec4Scale(out vOut: TD3DXVector4; const v: TD3DXVector4; s: Single): PD3DXVector4;
  753. {$EXTERNALSYM D3DXVec4Scale}
  754.  
  755. // Linear interpolation. V1 + s(V2-V1)
  756. function D3DXVec4Lerp(out vOut: TD3DXVector4;
  757.   const v1, v2: TD3DXVector4; s: Single): PD3DXVector4;
  758. {$EXTERNALSYM D3DXVec4Lerp}
  759.  
  760. // non-inline
  761.  
  762. // Cross-product in 4 dimensions.
  763. function D3DXVec4Cross(out vOut: TD3DXVector4;
  764.   const v1, v2, v3: TD3DXVector4): PD3DXVector4; stdcall; external d3dx9mathDLL;
  765. {$EXTERNALSYM D3DXVec4Cross}
  766.  
  767. function D3DXVec4Normalize(out vOut: TD3DXVector4;
  768.   const v: TD3DXVector4): PD3DXVector4; stdcall; external d3dx9mathDLL;
  769. {$EXTERNALSYM D3DXVec4Normalize}
  770.  
  771. // Hermite interpolation between position V1, tangent T1 (when s == 0)
  772. // and position V2, tangent T2 (when s == 1).
  773. function D3DXVec4Hermite(out vOut: TD3DXVector4;
  774.    const v1, t1, v2, t2: TD3DXVector4; s: Single): PD3DXVector4; stdcall; external d3dx9mathDLL;
  775. {$EXTERNALSYM D3DXVec4Hermite}
  776.  
  777. // CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1)
  778. function D3DXVec4CatmullRom(out vOut: TD3DXVector4;
  779.    const v0, v1, v2, v3: TD3DXVector4; s: Single): PD3DXVector4; stdcall; external d3dx9mathDLL;
  780. {$EXTERNALSYM D3DXVec4CatmullRom}
  781.  
  782. // Barycentric coordinates.  V1 + f(V2-V1) + g(V3-V1)
  783. function D3DXVec4BaryCentric(out vOut: TD3DXVector4;
  784.    const v1, v2, v3: TD3DXVector4; f, g: Single): PD3DXVector4; stdcall; external d3dx9mathDLL;
  785. {$EXTERNALSYM D3DXVec4BaryCentric}
  786.  
  787. // Transform vector by matrix.
  788. function D3DXVec4Transform(out vOut: TD3DXVector4;
  789.   const v: TD3DXVector4; const m: TD3DXMatrix): PD3DXVector4; stdcall; external d3dx9mathDLL;
  790. {$EXTERNALSYM D3DXVec4Transform}
  791.  
  792. // Transform vector array by matrix.
  793. function D3DXVec4TransformArray(pOut: PD3DXVector4; OutStride: LongWord;
  794.   pV: PD3DXVector4; VStride: LongWord; const m: TD3DXMatrix; n: LongWord): PD3DXVector4; stdcall; external d3dx9mathDLL;
  795. {$EXTERNALSYM D3DXVec4TransformArray}
  796.  
  797.  
  798. //--------------------------
  799. // 4D Matrix
  800. //--------------------------
  801.  
  802. // inline
  803.  
  804. function D3DXMatrixIdentity(out mOut: TD3DXMatrix): PD3DXMatrix;
  805. {$EXTERNALSYM D3DXMatrixIdentity}
  806.  
  807. function D3DXMatrixIsIdentity(const m: TD3DXMatrix): BOOL;
  808. {$EXTERNALSYM D3DXMatrixIsIdentity}
  809.  
  810. // non-inline
  811.  
  812. function D3DXMatrixDeterminant(const m: TD3DXMatrix): Single; stdcall; external d3dx9mathDLL;
  813. {$EXTERNALSYM D3DXMatrixDeterminant}
  814.  
  815. function D3DXMatrixTranspose(out pOut: TD3DXMatrix; const pM: TD3DXMatrix): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  816. {$EXTERNALSYM D3DXMatrixTranspose}
  817.  
  818. // Matrix multiplication.  The result represents the transformation M2
  819. // followed by the transformation M1.  (Out = M1 * M2)
  820. function D3DXMatrixMultiply(out mOut: TD3DXMatrix; const m1, m2: TD3DXMatrix): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  821. {$EXTERNALSYM D3DXMatrixMultiply}
  822.  
  823. // Matrix multiplication, followed by a transpose. (Out = T(M1 * M2))
  824. function D3DXMatrixMultiplyTranspose(out pOut: TD3DXMatrix; const pM1, pM2: TD3DXMatrix): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  825. {$EXTERNALSYM D3DXMatrixMultiplyTranspose}
  826.  
  827. // Calculate inverse of matrix.  Inversion my fail, in which case NULL will
  828. // be returned.  The determinant of pM is also returned it pfDeterminant
  829. // is non-NULL.
  830. function D3DXMatrixInverse(out mOut: TD3DXMatrix; pfDeterminant: PSingle;
  831.     const m: TD3DXMatrix): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  832. {$EXTERNALSYM D3DXMatrixInverse}
  833.  
  834. // Build a matrix which scales by (sx, sy, sz)
  835. function D3DXMatrixScaling(out mOut: TD3DXMatrix; sx, sy, sz: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  836. {$EXTERNALSYM D3DXMatrixScaling}
  837.  
  838. // Build a matrix which translates by (x, y, z)
  839. function D3DXMatrixTranslation(out mOut: TD3DXMatrix; x, y, z: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  840. {$EXTERNALSYM D3DXMatrixTranslation}
  841.  
  842. // Build a matrix which rotates around the X axis
  843. function D3DXMatrixRotationX(out mOut: TD3DXMatrix; angle: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  844. {$EXTERNALSYM D3DXMatrixRotationX}
  845.  
  846. // Build a matrix which rotates around the Y axis
  847. function D3DXMatrixRotationY(out mOut: TD3DXMatrix; angle: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  848. {$EXTERNALSYM D3DXMatrixRotationY}
  849.  
  850. // Build a matrix which rotates around the Z axis
  851. function D3DXMatrixRotationZ(out mOut: TD3DXMatrix; angle: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  852. {$EXTERNALSYM D3DXMatrixRotationZ}
  853.  
  854. // Build a matrix which rotates around an arbitrary axis
  855. function D3DXMatrixRotationAxis(out mOut: TD3DXMatrix; const v: TD3DXVector3;
  856.   angle: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  857. {$EXTERNALSYM D3DXMatrixRotationAxis}
  858.  
  859. // Build a matrix from a quaternion
  860. function D3DXMatrixRotationQuaternion(out mOut: TD3DXMatrix; const Q: TD3DXQuaternion): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  861. {$EXTERNALSYM D3DXMatrixRotationQuaternion}
  862.  
  863. // Yaw around the Y axis, a pitch around the X axis,
  864. // and a roll around the Z axis.
  865. function D3DXMatrixRotationYawPitchRoll(out mOut: TD3DXMatrix; yaw, pitch, roll: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  866. {$EXTERNALSYM D3DXMatrixRotationYawPitchRoll}
  867.  
  868.  
  869. // Build transformation matrix.  NULL arguments are treated as identity.
  870. // Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt
  871. function D3DXMatrixTransformation(out mOut: TD3DXMatrix;
  872.    pScalingCenter: PD3DXVector3;
  873.    pScalingRotation: PD3DXQuaternion; pScaling, pRotationCenter: PD3DXVector3;
  874.    pRotation: PD3DXQuaternion; pTranslation: PD3DXVector3): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  875. {$EXTERNALSYM D3DXMatrixTransformation}
  876.  
  877. // Build affine transformation matrix.  NULL arguments are treated as identity.
  878. // Mout = Ms * Mrc-1 * Mr * Mrc * Mt
  879. function D3DXMatrixAffineTransformation(out mOut: TD3DXMatrix;
  880.    Scaling: Single; pRotationCenter: PD3DXVector3;
  881.    pRotation: PD3DXQuaternion; pTranslation: PD3DXVector3): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  882. {$EXTERNALSYM D3DXMatrixAffineTransformation}
  883.  
  884. // Build a lookat matrix. (right-handed)
  885. function D3DXMatrixLookAtRH(out mOut: TD3DXMatrix; const Eye, At, Up: TD3DXVector3): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  886. {$EXTERNALSYM D3DXMatrixLookAtRH}
  887.  
  888. // Build a lookat matrix. (left-handed)
  889. function D3DXMatrixLookAtLH(out mOut: TD3DXMatrix; const Eye, At, Up: TD3DXVector3): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  890. {$EXTERNALSYM D3DXMatrixLookAtLH}
  891.  
  892. // Build a perspective projection matrix. (right-handed)
  893. function D3DXMatrixPerspectiveRH(out mOut: TD3DXMatrix; w, h, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  894. {$EXTERNALSYM D3DXMatrixPerspectiveRH}
  895.  
  896. // Build a perspective projection matrix. (left-handed)
  897. function D3DXMatrixPerspectiveLH(out mOut: TD3DXMatrix; w, h, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  898. {$EXTERNALSYM D3DXMatrixPerspectiveLH}
  899.  
  900. // Build a perspective projection matrix. (right-handed)
  901. function D3DXMatrixPerspectiveFovRH(out mOut: TD3DXMatrix; flovy, aspect, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  902. {$EXTERNALSYM D3DXMatrixPerspectiveFovRH}
  903.  
  904. // Build a perspective projection matrix. (left-handed)
  905. function D3DXMatrixPerspectiveFovLH(out mOut: TD3DXMatrix; flovy, aspect, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  906. {$EXTERNALSYM D3DXMatrixPerspectiveFovLH}
  907.  
  908. // Build a perspective projection matrix. (right-handed)
  909. function D3DXMatrixPerspectiveOffCenterRH(out mOut: TD3DXMatrix;
  910.    l, r, b, t, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  911. {$EXTERNALSYM D3DXMatrixPerspectiveOffCenterRH}
  912.  
  913. // Build a perspective projection matrix. (left-handed)
  914. function D3DXMatrixPerspectiveOffCenterLH(out mOut: TD3DXMatrix;
  915.    l, r, b, t, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  916. {$EXTERNALSYM D3DXMatrixPerspectiveOffCenterLH}
  917.  
  918. // Build an ortho projection matrix. (right-handed)
  919. function D3DXMatrixOrthoRH(out mOut: TD3DXMatrix; w, h, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  920. {$EXTERNALSYM D3DXMatrixOrthoRH}
  921.  
  922. // Build an ortho projection matrix. (left-handed)
  923. function D3DXMatrixOrthoLH(out mOut: TD3DXMatrix; w, h, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  924. {$EXTERNALSYM D3DXMatrixOrthoLH}
  925.  
  926. // Build an ortho projection matrix. (right-handed)
  927. function D3DXMatrixOrthoOffCenterRH(out mOut: TD3DXMatrix;
  928.   l, r, b, t, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  929. {$EXTERNALSYM D3DXMatrixOrthoOffCenterRH}
  930.  
  931. // Build an ortho projection matrix. (left-handed)
  932. function D3DXMatrixOrthoOffCenterLH(out mOut: TD3DXMatrix;
  933.   l, r, b, t, zn, zf: Single): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  934. {$EXTERNALSYM D3DXMatrixOrthoOffCenterLH}
  935.  
  936. // Build a matrix which flattens geometry into a plane, as if casting
  937. // a shadow from a light.
  938. function D3DXMatrixShadow(out mOut: TD3DXMatrix;
  939.   const Light: TD3DXVector4; const Plane: TD3DXPlane): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  940. {$EXTERNALSYM D3DXMatrixShadow}
  941.  
  942. // Build a matrix which reflects the coordinate system about a plane
  943. function D3DXMatrixReflect(out mOut: TD3DXMatrix;
  944.    const Plane: TD3DXPlane): PD3DXMatrix; stdcall; external d3dx9mathDLL;
  945. {$EXTERNALSYM D3DXMatrixReflect}
  946.  
  947.  
  948. //--------------------------
  949. // Quaternion
  950. //--------------------------
  951.  
  952. // inline
  953.  
  954. function D3DXQuaternionLength(const q: TD3DXQuaternion): Single;
  955. {$EXTERNALSYM D3DXQuaternionLength}
  956.  
  957. // Length squared, or "norm"
  958. function D3DXQuaternionLengthSq(const q: TD3DXQuaternion): Single;
  959. {$EXTERNALSYM D3DXQuaternionLengthSq}
  960.  
  961. function D3DXQuaternionDot(const q1, q2: TD3DXQuaternion): Single;
  962. {$EXTERNALSYM D3DXQuaternionDot}
  963.  
  964. // (0, 0, 0, 1)
  965. function D3DXQuaternionIdentity(out qOut: TD3DXQuaternion): PD3DXQuaternion;
  966. {$EXTERNALSYM D3DXQuaternionIdentity}
  967.  
  968. function D3DXQuaternionIsIdentity (const q: TD3DXQuaternion): BOOL;
  969. {$EXTERNALSYM D3DXQuaternionIsIdentity}
  970.  
  971. // (-x, -y, -z, w)
  972. function D3DXQuaternionConjugate(out qOut: TD3DXQuaternion;
  973.   const q: TD3DXQuaternion): PD3DXQuaternion;
  974. {$EXTERNALSYM D3DXQuaternionConjugate}
  975.  
  976.  
  977. // non-inline
  978.  
  979. // Compute a quaternin's axis and angle of rotation. Expects unit quaternions.
  980. procedure D3DXQuaternionToAxisAngle(const q: TD3DXQuaternion;
  981.   out Axis: TD3DXVector3; out Angle: Single); stdcall; external d3dx9mathDLL;
  982. {$EXTERNALSYM D3DXQuaternionToAxisAngle}
  983.  
  984. // Build a quaternion from a rotation matrix.
  985. function D3DXQuaternionRotationMatrix(out qOut: TD3DXQuaternion;
  986.   const m: TD3DXMatrix): PD3DXQuaternion; stdcall; external d3dx9mathDLL;
  987. {$EXTERNALSYM D3DXQuaternionRotationMatrix}
  988.  
  989. // Rotation about arbitrary axis.
  990. function D3DXQuaternionRotationAxis(out qOut: TD3DXQuaternion;
  991.   const v: TD3DXVector3; Angle: Single): PD3DXQuaternion; stdcall; external d3dx9mathDLL;
  992. {$EXTERNALSYM D3DXQuaternionRotationAxis}
  993.  
  994. // Yaw around the Y axis, a pitch around the X axis,
  995. // and a roll around the Z axis.
  996. function D3DXQuaternionRotationYawPitchRoll(out qOut: TD3DXQuaternion;
  997.   yaw, pitch, roll: Single): PD3DXQuaternion; stdcall; external d3dx9mathDLL;
  998. {$EXTERNALSYM D3DXQuaternionRotationYawPitchRoll}
  999.  
  1000. // Quaternion multiplication.  The result represents the rotation Q2
  1001. // followed by the rotation Q1.  (Out = Q2 * Q1)
  1002. function D3DXQuaternionMultiply(out qOut: TD3DXQuaternion;
  1003.    const q1, q2: TD3DXQuaternion): PD3DXQuaternion; stdcall; external d3dx9mathDLL;
  1004. {$EXTERNALSYM D3DXQuaternionMultiply}
  1005.  
  1006. function D3DXQuaternionNormalize(out qOut: TD3DXQuaternion;
  1007.    const q: TD3DXQuaternion): PD3DXQuaternion; stdcall; external d3dx9mathDLL;
  1008. {$EXTERNALSYM D3DXQuaternionNormalize}
  1009.  
  1010. // Conjugate and re-norm
  1011. function D3DXQuaternionInverse(out qOut: TD3DXQuaternion;
  1012.    const q: TD3DXQuaternion): PD3DXQuaternion; stdcall; external d3dx9mathDLL;
  1013. {$EXTERNALSYM D3DXQuaternionInverse}
  1014.  
  1015. // Expects unit quaternions.
  1016. // if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v)
  1017. function D3DXQuaternionLn(out qOut: TD3DXQuaternion;
  1018.    const q: TD3DXQuaternion): PD3DXQuaternion; stdcall; external d3dx9mathDLL;
  1019. {$EXTERNALSYM D3DXQuaternionLn}
  1020.  
  1021. // Expects pure quaternions. (w == 0)  w is ignored in calculation.
  1022. // if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v)
  1023. function D3DXQuaternionExp(out qOut: TD3DXQuaternion;
  1024.    const q: TD3DXQuaternion): PD3DXQuaternion; stdcall; external d3dx9mathDLL;
  1025. {$EXTERNALSYM D3DXQuaternionExp}
  1026.  
  1027. // Spherical linear interpolation between Q1 (s == 0) and Q2 (s == 1).
  1028. // Expects unit quaternions.
  1029. function D3DXQuaternionSlerp(out qOut: TD3DXQuaternion;
  1030.    const q1, q2: TD3DXQuaternion; t: Single): PD3DXQuaternion; stdcall; external d3dx9mathDLL;
  1031. {$EXTERNALSYM D3DXQuaternionSlerp}
  1032.  
  1033. // Spherical quadrangle interpolation.
  1034. // Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t))
  1035. function D3DXQuaternionSquad(out qOut: TD3DXQuaternion;
  1036.    const pQ1, pA, pB, pC: TD3DXQuaternion; t: Single): PD3DXQuaternion; stdcall; external d3dx9mathDLL;
  1037. {$EXTERNALSYM D3DXQuaternionSquad}
  1038.  
  1039. // Setup control points for spherical quadrangle interpolation
  1040. // from Q1 to Q2.  The control points are chosen in such a way
  1041. // to ensure the continuity of tangents with adjacent segments.
  1042. procedure D3DXQuaternionSquadSetup(out pAOut, pBOut, pCOut: TD3DXQuaternion;
  1043.    const pQ0, pQ1, pQ2, pQ3: TD3DXQuaternion); stdcall; external d3dx9mathDLL;
  1044. {$EXTERNALSYM D3DXQuaternionSquadSetup}
  1045.  
  1046. // Barycentric interpolation.
  1047. // Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g))
  1048. function D3DXQuaternionBaryCentric(out qOut: TD3DXQuaternion;
  1049.    const q1, q2, q3: TD3DXQuaternion; f, g: Single): PD3DXQuaternion; stdcall; external d3dx9mathDLL;
  1050. {$EXTERNALSYM D3DXQuaternionBaryCentric}
  1051.  
  1052.  
  1053. //--------------------------
  1054. // Plane
  1055. //--------------------------
  1056.  
  1057. // inline
  1058.  
  1059. // ax + by + cz + dw
  1060. function D3DXPlaneDot(const p: TD3DXPlane; const v: TD3DXVector4): Single;
  1061. {$EXTERNALSYM D3DXPlaneDot}
  1062.  
  1063. // ax + by + cz + d
  1064. function D3DXPlaneDotCoord(const p: TD3DXPlane; const v: TD3DXVector3): Single;
  1065. {$EXTERNALSYM D3DXPlaneDotCoord}
  1066.  
  1067. // ax + by + cz
  1068. function D3DXPlaneDotNormal(const p: TD3DXPlane; const v: TD3DXVector3): Single;
  1069. {$EXTERNALSYM D3DXPlaneDotNormal}
  1070.  
  1071.  
  1072. // non-inline
  1073.  
  1074. // Normalize plane (so that |a,b,c| == 1)
  1075. function D3DXPlaneNormalize(out pOut: TD3DXPlane; const p: TD3DXPlane): PD3DXPlane; stdcall; external d3dx9mathDLL;
  1076. {$EXTERNALSYM D3DXPlaneNormalize}
  1077.  
  1078. // Find the intersection between a plane and a line.  If the line is
  1079. // parallel to the plane, NULL is returned.
  1080. function D3DXPlaneIntersectLine(out vOut: TD3DXVector3;
  1081.    const p: TD3DXPlane; const v1, v2: TD3DXVector3): PD3DXVector3; stdcall; external d3dx9mathDLL;
  1082. {$EXTERNALSYM D3DXPlaneIntersectLine}
  1083.  
  1084. // Construct a plane from a point and a normal
  1085. function D3DXPlaneFromPointNormal(out pOut: TD3DXPlane;
  1086.    const vPoint, vNormal: TD3DXVector3): PD3DXPlane; stdcall; external d3dx9mathDLL;
  1087. {$EXTERNALSYM D3DXPlaneFromPointNormal}
  1088.  
  1089. // Construct a plane from 3 points
  1090. function D3DXPlaneFromPoints(out pOut: TD3DXPlane;
  1091.    const v1, v2, v3: TD3DXVector3): PD3DXPlane; stdcall; external d3dx9mathDLL;
  1092. {$EXTERNALSYM D3DXPlaneFromPoints}
  1093.  
  1094. // Transform a plane by a matrix.  The vector (a,b,c) must be normal.
  1095. // M should be the inverse transpose of the transformation desired.
  1096. function D3DXPlaneTransform(out pOut: TD3DXPlane; const m: TD3DXMatrix): PD3DXPlane; stdcall; external d3dx9mathDLL;
  1097. {$EXTERNALSYM D3DXPlaneTransform}
  1098.  
  1099. // Transform an array of planes by a matrix.  The vectors (a,b,c) must be normal.
  1100. // M should be the inverse transpose of the transformation desired.
  1101. function D3DXPlaneTransformArray(pOut: PD3DXPlane; OutStride: LongWord;
  1102.   pP: PD3DXPlane; PStride: LongWord; const m: TD3DXMatrix; n: LongWord): PD3DXPlane; stdcall; external d3dx9mathDLL;
  1103. {$EXTERNALSYM D3DXPlaneTransformArray}
  1104.  
  1105.  
  1106. //--------------------------
  1107. // Color
  1108. //--------------------------
  1109.  
  1110. // inline
  1111.  
  1112. // (1-r, 1-g, 1-b, a)
  1113. function D3DXColorNegative(out cOut: TD3DXColor; const c: TD3DXColor): PD3DXColor;
  1114. {$EXTERNALSYM D3DXColorNegative}
  1115.  
  1116. function D3DXColorAdd(out cOut: TD3DXColor; const c1, c2: TD3DXColor): PD3DXColor;
  1117. {$EXTERNALSYM D3DXColorAdd}
  1118.  
  1119. function D3DXColorSubtract(out cOut: TD3DXColor; const c1, c2: TD3DXColor): PD3DXColor;
  1120. {$EXTERNALSYM D3DXColorSubtract}
  1121.  
  1122. function D3DXColorScale(out cOut: TD3DXColor; const c: TD3DXColor; s: Single): PD3DXColor;
  1123. {$EXTERNALSYM D3DXColorScale}
  1124.  
  1125. // (r1*r2, g1*g2, b1*b2, a1*a2)
  1126. function D3DXColorModulate(out cOut: TD3DXColor; const c1, c2: TD3DXColor): PD3DXColor;
  1127. {$EXTERNALSYM D3DXColorModulate}
  1128.  
  1129. // Linear interpolation of r,g,b, and a. C1 + s(C2-C1)
  1130. function D3DXColorLerp(out cOut: TD3DXColor; const c1, c2: TD3DXColor; s: Single): PD3DXColor;
  1131. {$EXTERNALSYM D3DXColorLerp}
  1132.  
  1133. // non-inline
  1134.  
  1135. // Interpolate r,g,b between desaturated color and color.
  1136. // DesaturatedColor + s(Color - DesaturatedColor)
  1137. function D3DXColorAdjustSaturation(out cOut: TD3DXColor;
  1138.    const pC: TD3DXColor; s: Single): PD3DXColor; stdcall; external d3dx9mathDLL;
  1139. {$EXTERNALSYM D3DXColorAdjustSaturation}
  1140.  
  1141. // Interpolate r,g,b between 50% grey and color.  Grey + s(Color - Grey)
  1142. function D3DXColorAdjustContrast(out cOut: TD3DXColor;
  1143.    const pC: TD3DXColor; c: Single): PD3DXColor; stdcall; external d3dx9mathDLL;
  1144. {$EXTERNALSYM D3DXColorAdjustContrast}
  1145.  
  1146.  
  1147. //--------------------------
  1148. // Misc
  1149. //--------------------------
  1150.  
  1151. // Calculate Fresnel term given the cosine of theta (likely obtained by
  1152. // taking the dot of two normals), and the refraction index of the material.
  1153. function D3DXFresnelTerm(CosTheta, RefractionIndex: Single): Single; stdcall; external d3dx9mathDLL;
  1154. {$EXTERNALSYM D3DXFresnelTerm}
  1155.  
  1156.  
  1157.  
  1158. //===========================================================================
  1159. //
  1160. //    Matrix Stack
  1161. //
  1162. //===========================================================================
  1163.  
  1164. type
  1165.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXMatrixStack);'}
  1166.   {$EXTERNALSYM ID3DXMatrixStack}
  1167.   ID3DXMatrixStack = interface(IUnknown)
  1168.     ['{E3357330-CC5E-11d2-A434-00A0C90629A8}']
  1169.     //
  1170.     // ID3DXMatrixStack methods
  1171.     //
  1172.  
  1173.     // Pops the top of the stack, returns the current top
  1174.     // *after* popping the top.
  1175.     function Pop: HResult; stdcall;
  1176.  
  1177.     // Pushes the stack by one, duplicating the current matrix.
  1178.     function Push: HResult; stdcall;
  1179.  
  1180.     // Loads identity in the current matrix.
  1181.     function LoadIdentity: HResult; stdcall;
  1182.  
  1183.     // Loads the given matrix into the current matrix
  1184.     function LoadMatrix(const M: TD3DXMatrix): HResult; stdcall;
  1185.  
  1186.     // Right-Multiplies the given matrix to the current matrix.
  1187.     // (transformation is about the current world origin)
  1188.     function MultMatrix(const M: TD3DXMatrix): HResult; stdcall;
  1189.  
  1190.     // Left-Multiplies the given matrix to the current matrix
  1191.     // (transformation is about the local origin of the object)
  1192.     function MultMatrixLocal(const M: TD3DXMatrix): HResult; stdcall;
  1193.  
  1194.     // Right multiply the current matrix with the computed rotation
  1195.     // matrix, counterclockwise about the given axis with the given angle.
  1196.     // (rotation is about the current world origin)
  1197.     function RotateAxis(const V: TD3DXVector3; Angle: Single): HResult; stdcall;
  1198.  
  1199.     // Left multiply the current matrix with the computed rotation
  1200.     // matrix, counterclockwise about the given axis with the given angle.
  1201.     // (rotation is about the local origin of the object)
  1202.     function RotateAxisLocal(const V: TD3DXVector3; Angle: Single): HResult; stdcall;
  1203.  
  1204.     // Right multiply the current matrix with the computed rotation
  1205.     // matrix. All angles are counterclockwise. (rotation is about the
  1206.     // current world origin)
  1207.  
  1208.     // The rotation is composed of a yaw around the Y axis, a pitch around
  1209.     // the X axis, and a roll around the Z axis.
  1210.     function RotateYawPitchRoll(yaw, pitch, roll: Single): HResult; stdcall;
  1211.  
  1212.     // Left multiply the current matrix with the computed rotation
  1213.     // matrix. All angles are counterclockwise. (rotation is about the
  1214.     // local origin of the object)
  1215.  
  1216.     // The rotation is composed of a yaw around the Y axis, a pitch around
  1217.     // the X axis, and a roll around the Z axis.
  1218.     function RotateYawPitchRollLocal(yaw, pitch, roll: Single): HResult; stdcall;
  1219.  
  1220.     // Right multiply the current matrix with the computed scale
  1221.     // matrix. (transformation is about the current world origin)
  1222.     function Scale(x, y, z: Single): HResult; stdcall;
  1223.  
  1224.     // Left multiply the current matrix with the computed scale
  1225.     // matrix. (transformation is about the local origin of the object)
  1226.     function ScaleLocal(x, y, z: Single): HResult; stdcall;
  1227.  
  1228.     // Right multiply the current matrix with the computed translation
  1229.     // matrix. (transformation is about the current world origin)
  1230.     function Translate(x, y, z: Single): HResult; stdcall;
  1231.  
  1232.     // Left multiply the current matrix with the computed translation
  1233.     // matrix. (transformation is about the local origin of the object)
  1234.     function TranslateLocal(x, y, z: Single): HResult; stdcall;
  1235.  
  1236.     // Obtain the current matrix at the top of the stack
  1237.     function GetTop: PD3DXMatrix; stdcall;
  1238.   end;
  1239.  
  1240. type
  1241.   IID_ID3DXMatrixStack = ID3DXMatrixStack;
  1242.   {$EXTERNALSYM IID_ID3DXMatrixStack}
  1243.  
  1244. function D3DXCreateMatrixStack(Flags: DWord; out Stack: ID3DXMatrixStack): HResult; stdcall; external d3dx9mathDLL;
  1245. {$EXTERNALSYM D3DXCreateMatrixStack}
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253. ///////////////////////////////////////////////////////////////////////////
  1254. //
  1255. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  1256. //
  1257. //  File:       d3dx9core.h
  1258. //  Content:    D3DX core types and functions
  1259. //
  1260. ///////////////////////////////////////////////////////////////////////////
  1261.  
  1262.  
  1263. ///////////////////////////////////////////////////////////////////////////
  1264. // D3DX_SDK_VERSION:
  1265. // -----------------
  1266. // This identifier is passed to D3DXCheckVersion in order to ensure that an
  1267. // application was built against the correct header files and lib files.
  1268. // This number is incremented whenever a header (or other) change would
  1269. // require applications to be rebuilt. If the version doesn't match,
  1270. // D3DXCreateVersion will return FALSE. (The number itself has no meaning.)
  1271. ///////////////////////////////////////////////////////////////////////////
  1272.  
  1273. const
  1274.   D3DX_VERSION          = 0900;
  1275.   {$EXTERNALSYM D3DX_VERSION}
  1276.   D3DX_SDK_VERSION      = 9;
  1277.   {$EXTERNALSYM D3DX_SDK_VERSION}
  1278.  
  1279. function D3DXCheckVersion(D3DSdkVersion, D3DXSdkVersion: LongWord): BOOL; stdcall; external d3dx9coreDLL;
  1280. {$EXTERNALSYM D3DXCheckVersion}
  1281.  
  1282.  
  1283.  
  1284. ///////////////////////////////////////////////////////////////////////////
  1285. // D3DXGetDriverLevel:
  1286. //    Returns driver version information:
  1287. //
  1288. //    700 - DX7 level driver
  1289. //    800 - DX8 level driver
  1290. //    900 - DX9 level driver
  1291. ///////////////////////////////////////////////////////////////////////////
  1292.  
  1293. function D3DXGetDriverLevel(pDevice: IDirect3DDevice9): LongWord; stdcall; external d3dx9coreDLL;
  1294. {$EXTERNALSYM D3DXGetDriverLevel}
  1295.  
  1296.  
  1297. ///////////////////////////////////////////////////////////////////////////
  1298. // ID3DXBuffer:
  1299. // ------------
  1300. // The buffer object is used by D3DX to return arbitrary size data.
  1301. //
  1302. // GetBufferPointer -
  1303. //    Returns a pointer to the beginning of the buffer.
  1304. //
  1305. // GetBufferSize -
  1306. //    Returns the size of the buffer, in bytes.
  1307. ///////////////////////////////////////////////////////////////////////////
  1308.  
  1309. type
  1310.   PID3DXBuffer = ^ID3DXBuffer;
  1311.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXBuffer);'}
  1312.   {$EXTERNALSYM ID3DXBuffer}
  1313.   ID3DXBuffer = interface(IUnknown)
  1314.     ['{932E6A7E-C68E-45dd-A7BF-53D19C86DB1F}']
  1315.     // ID3DXBuffer
  1316.     function GetBufferPointer: Pointer; stdcall;
  1317.     function GetBufferSize: DWord; stdcall;
  1318.   end;
  1319.  
  1320.  
  1321.  
  1322. ///////////////////////////////////////////////////////////////////////////
  1323. // ID3DXFont:
  1324. // ----------
  1325. // Font objects contain the textures and resources needed to render
  1326. // a specific font on a specific device.
  1327. //
  1328. // Begin -
  1329. //    Prepartes device for drawing text.  This is optional.. if DrawText
  1330. //    is called outside of Begin/End, it will call Begin and End for you.
  1331. //
  1332. // DrawText -
  1333. //    Draws formatted text on a D3D device.  Some parameters are
  1334. //    surprisingly similar to those of GDI's DrawText function.  See GDI
  1335. //    documentation for a detailed description of these parameters.
  1336. //
  1337. // End -
  1338. //    Restores device state to how it was when Begin was called.
  1339. //
  1340. // OnLostDevice, OnResetDevice -
  1341. //    Call OnLostDevice() on this object before calling Reset() on the
  1342. //    device, so that this object can release any stateblocks and video
  1343. //    memory resources.  After Reset(), the call OnResetDevice().
  1344. //
  1345. ///////////////////////////////////////////////////////////////////////////
  1346.  
  1347.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXFont);'}
  1348.   {$EXTERNALSYM ID3DXFont}
  1349.   ID3DXFont = interface(IUnknown)
  1350.     ['{4AAE6B4D-D15F-4909-B09F-8D6AA34AC06B}']
  1351.     // ID3DXFont
  1352.     function GetDevice(out ppDevice: IDirect3DDevice9): HResult; stdcall;
  1353.     function GetLogFont(out pLogFont: TLogFont): HResult; stdcall;
  1354.  
  1355.     function _Begin: HResult; stdcall;
  1356.     function DrawTextA(pString: PAnsiChar; Count: Integer; const pRect: TRect; Format: DWord; Color: TD3DColor): Integer; stdcall;
  1357.     function DrawTextW(pString: PWideChar; Count: Integer; const pRect: TRect; Format: DWord; Color: TD3DColor): Integer; stdcall;
  1358.     function _End: HResult; stdcall;
  1359.  
  1360.     function OnLostDevice: HResult; stdcall;
  1361.     function OnResetDevice: HResult; stdcall;
  1362.   end;
  1363.  
  1364.  
  1365. function D3DXCreateFont(pDevice: IDirect3DDevice9; hFont: HFONT;
  1366.   out ppFont: ID3DXFont): HResult; stdcall; external d3dx9coreDLL;
  1367. {$EXTERNALSYM D3DXCreateFont}
  1368.  
  1369. function D3DXCreateFontIndirect(pDevice: IDirect3DDevice9;
  1370.   const pLogFont: TLogFont; out ppFont: ID3DXFont): HResult; stdcall; external d3dx9coreDLL;
  1371. {$EXTERNALSYM D3DXCreateFontIndirect}
  1372.  
  1373.  
  1374.  
  1375. ///////////////////////////////////////////////////////////////////////////
  1376. // ID3DXSprite:
  1377. // ------------
  1378. // This object intends to provide an easy way to drawing sprites using D3D.
  1379. //
  1380. // Begin -
  1381. //    Prepares device for drawing sprites
  1382. //
  1383. // Draw, DrawAffine, DrawTransform -
  1384. //    Draws a sprite in screen-space.  Before transformation, the sprite is
  1385. //    the size of SrcRect, with its top-left corner at the origin (0,0).
  1386. //    The color and alpha channels are modulated by Color.
  1387. //
  1388. // End -
  1389. //     Restores device state to how it was when Begin was called.
  1390. //
  1391. // OnLostDevice, OnResetDevice -
  1392. //    Call OnLostDevice() on this object before calling Reset() on the
  1393. //    device, so that this object can release any stateblocks and video
  1394. //    memory resources.  After Reset(), the call OnResetDevice().
  1395. ///////////////////////////////////////////////////////////////////////////
  1396. type
  1397.  
  1398.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXSprite);'}
  1399.   {$EXTERNALSYM ID3DXSprite}
  1400.   ID3DXSprite = interface(IUnknown)
  1401.     ['{B07EC84A-8D35-4e86-A9A0-8DFF21D71075}']
  1402.     // ID3DXSprite
  1403.     function GetDevice(out ppDevice: IDirect3DDevice9): HResult; stdcall;
  1404.  
  1405.     function _Begin: HResult; stdcall;
  1406.  
  1407.     function Draw(pSrcTexture: IDirect3DTexture9; pSrcRect: PRect;
  1408.       pScaling, pRotationCenter: PD3DXVector2; Rotation: Single;
  1409.       pTranslation: PD3DXVector2; Color: TD3DColor): HResult; stdcall;
  1410.  
  1411.     function DrawTransform(pSrcTexture: IDirect3DTexture9; pSrcRect: PRect;
  1412.       const pTransform: TD3DXMatrix; Color: TD3DColor): HResult; stdcall;
  1413.  
  1414.     function _End: HResult; stdcall;
  1415.  
  1416.     function OnLostDevice: HResult; stdcall;
  1417.     function OnResetDevice: HResult; stdcall;
  1418.   end;
  1419.  
  1420.  
  1421. function D3DXCreateSprite(ppDevice: IDirect3DDevice9;
  1422.   out ppSprite: ID3DXSprite): HResult; stdcall; external d3dx9coreDLL;
  1423. {$EXTERNALSYM D3DXCreateSprite}
  1424.  
  1425.  
  1426.  
  1427. ///////////////////////////////////////////////////////////////////////////
  1428. // ID3DXRenderToSurface:
  1429. // ---------------------
  1430. // This object abstracts rendering to surfaces.  These surfaces do not
  1431. // necessarily need to be render targets.  If they are not, a compatible
  1432. // render target is used, and the result copied into surface at end scene.
  1433. //
  1434. // BeginScene, EndScene -
  1435. //    Call BeginScene() and EndScene() at the beginning and ending of your
  1436. //    scene.  These calls will setup and restore render targets, viewports,
  1437. //    etc..
  1438. //
  1439. // OnLostDevice, OnResetDevice -
  1440. //    Call OnLostDevice() on this object before calling Reset() on the
  1441. //    device, so that this object can release any stateblocks and video
  1442. //    memory resources.  After Reset(), the call OnResetDevice().
  1443. ///////////////////////////////////////////////////////////////////////////
  1444. type
  1445.  
  1446.   PD3DXRTSDesc = ^TD3DXRTSDesc;
  1447.   _D3DXRTS_DESC = packed record
  1448.     Width: LongWord;
  1449.     Height: LongWord;
  1450.     Format: TD3DFormat;
  1451.     DepthStencil: BOOL;
  1452.     DepthStencilFormat: TD3DFormat;
  1453.   end {_D3DXRTS_DESC};
  1454.   {$EXTERNALSYM _D3DXRTS_DESC}
  1455.   D3DXRTS_DESC = _D3DXRTS_DESC;
  1456.   {$EXTERNALSYM D3DXRTS_DESC}
  1457.   TD3DXRTSDesc = _D3DXRTS_DESC;
  1458.  
  1459.  
  1460.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXRenderToSurface);'}
  1461.   {$EXTERNALSYM ID3DXRenderToSurface}
  1462.   ID3DXRenderToSurface = interface(IUnknown)
  1463.     ['{0D014791-8863-4c2c-A1C0-02F3E0C0B653}']
  1464.     // ID3DXRenderToSurface
  1465.     function GetDevice(out ppDevice: IDirect3DDevice9): HResult; stdcall;
  1466.     function GetDesc(out pDesc: TD3DXRTSDesc): HResult; stdcall;
  1467.  
  1468.     function BeginScene(pSurface: IDirect3DSurface9; pViewport: PD3DViewport9): HResult; stdcall;
  1469.     function EndScene(MipFilter: DWORD): HResult; stdcall;
  1470.  
  1471.     function OnLostDevice: HResult; stdcall;
  1472.     function OnResetDevice: HResult; stdcall;
  1473.   end;
  1474.  
  1475.  
  1476. function D3DXCreateRenderToSurface(ppDevice: IDirect3DDevice9;
  1477.   Width: LongWord;
  1478.   Height: LongWord;
  1479.   Format: TD3DFormat;
  1480.   DepthStencil: BOOL;
  1481.   DepthStencilFormat: TD3DFormat;
  1482.   out ppRenderToSurface: ID3DXRenderToSurface): HResult; stdcall; external d3dx9coreDLL;
  1483. {$EXTERNALSYM D3DXCreateRenderToSurface}
  1484.  
  1485.  
  1486.  
  1487.  
  1488. ///////////////////////////////////////////////////////////////////////////
  1489. // ID3DXRenderToEnvMap:
  1490. // --------------------
  1491. // This object abstracts rendering to environment maps.  These surfaces
  1492. // do not necessarily need to be render targets.  If they are not, a
  1493. // compatible render target is used, and the result copied into the
  1494. // environment map at end scene.
  1495. //
  1496. // BeginCube, BeginSphere, BeginHemisphere, BeginParabolic -
  1497. //    This function initiates the rendering of the environment map.  As
  1498. //    parameters, you pass the textures in which will get filled in with
  1499. //    the resulting environment map.
  1500. //
  1501. // Face -
  1502. //    Call this function to initiate the drawing of each face.  For each
  1503. //    environment map, you will call this six times.. once for each face
  1504. //    in D3DCUBEMAP_FACES.
  1505. //
  1506. // End -
  1507. //    This will restore all render targets, and if needed compose all the
  1508. //    rendered faces into the environment map surfaces.
  1509. //
  1510. // OnLostDevice, OnResetDevice -
  1511. //    Call OnLostDevice() on this object before calling Reset() on the
  1512. //    device, so that this object can release any stateblocks and video
  1513. //    memory resources.  After Reset(), the call OnResetDevice().
  1514. ///////////////////////////////////////////////////////////////////////////
  1515. type
  1516.  
  1517.   PD3DXRTEDesc = ^TD3DXRTEDesc;
  1518.   _D3DXRTE_DESC = record
  1519.     Size: LongWord;
  1520.     MipLevels: LongWord;
  1521.     Format: TD3DFormat;
  1522.     DepthStencil: Bool;
  1523.     DepthStencilFormat: TD3DFormat;
  1524.   end {_D3DXRTE_DESC};
  1525.   {$EXTERNALSYM _D3DXRTE_DESC}
  1526.   D3DXRTE_DESC = _D3DXRTE_DESC;
  1527.   {$EXTERNALSYM D3DXRTE_DESC}
  1528.   TD3DXRTEDesc = _D3DXRTE_DESC;
  1529.  
  1530.  
  1531.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXRenderToEnvMap);'}
  1532.   {$EXTERNALSYM ID3DXRenderToEnvMap}
  1533.   ID3DXRenderToEnvMap = interface(IUnknown)
  1534.     ['{1561135E-BC78-495b-8586-94EA537BD557}']
  1535.     // ID3DXRenderToEnvMap
  1536.     function GetDevice(out ppDevice: IDirect3DDevice9): HResult; stdcall;
  1537.     function GetDesc(out pDesc: TD3DXRTEDesc): HResult; stdcall;
  1538.  
  1539.     function BeginCube(pCubeTex: IDirect3DCubeTexture9): HResult; stdcall;
  1540.  
  1541.     function BeginSphere(pTex: IDirect3DTexture9): HResult; stdcall;
  1542.  
  1543.     function BeginHemisphere(pTexZPos, pTexZNeg: IDirect3DTexture9): HResult; stdcall;
  1544.  
  1545.     function BeginParabolic(pTexZPos, pTexZNeg: IDirect3DTexture9): HResult; stdcall;
  1546.  
  1547.     function Face(Face: TD3DCubemapFaces; MipFilter: DWORD): HResult; stdcall;
  1548.     function _End(MipFilter: DWORD): HResult; stdcall;
  1549.  
  1550.     function OnLostDevice: HResult; stdcall;
  1551.     function OnResetDevice: HResult; stdcall;
  1552.   end;
  1553.  
  1554.  
  1555. function D3DXCreateRenderToEnvMap(ppDevice: IDirect3DDevice9;
  1556.   Size: LongWord;
  1557.   MipLevels: LongWord;
  1558.   Format: TD3DFormat;
  1559.   DepthStencil: BOOL;
  1560.   DepthStencilFormat: TD3DFormat;
  1561.   out ppRenderToEnvMap: ID3DXRenderToEnvMap): HResult; stdcall; external d3dx9coreDLL;
  1562. {$EXTERNALSYM D3DXCreateRenderToEnvMap}
  1563.  
  1564.  
  1565.  
  1566. ///////////////////////////////////////////////////////////////////////////
  1567. // ID3DXLine:
  1568. // ------------
  1569. // This object intends to provide an easy way to draw lines using D3D.
  1570. //
  1571. // Begin -
  1572. //    Prepares device for drawing lines
  1573. //
  1574. // Draw -
  1575. //    Draws a line strip in screen-space.
  1576. //    Input is in the form of a array defining points on the line strip. of D3DXVECTOR2 
  1577. //
  1578. // DrawTransform -
  1579. //    Draws a line in screen-space with a specified input transformation matrix.
  1580. //
  1581. // End - 
  1582. //     Restores device state to how it was when Begin was called.
  1583. //
  1584. // SetPattern - 
  1585. //     Applies a stipple pattern to the line.  Input is one 32-bit
  1586. //     DWORD which describes the stipple pattern. 1 is opaque, 0 is
  1587. //     transparent.
  1588. //
  1589. // SetPatternScale -
  1590. //     Stretches the stipple pattern in the u direction.  Input is one
  1591. //     floating-point value.  0.0f is no scaling, whereas 1.0f doubles
  1592. //     the length of the stipple pattern.
  1593. //
  1594. // SetWidth - 
  1595. //     Specifies the thickness of the line in the v direction.  Input is
  1596. //     one floating-point value.
  1597. //
  1598. // SetAntialias - 
  1599. //     Toggles line antialiasing.  Input is a BOOL.
  1600. //     TRUE  = Antialiasing on.
  1601. //     FALSE = Antialiasing off.
  1602. //
  1603. // SetGLLines - 
  1604. //     Toggles non-antialiased OpenGL line emulation.  Input is a BOOL.
  1605. //     TRUE  = OpenGL line emulation on.
  1606. //     FALSE = OpenGL line emulation off.
  1607. //
  1608. // OpenGL line:     Regular line:
  1609. //   *\                *\
  1610. //   | \              /  \
  1611. //   |  \            *\   \
  1612. //   *\  \             \   \
  1613. //     \  \             \   \
  1614. //      \  *             \   *
  1615. //       \ |              \ /
  1616. //        \|               *
  1617. //         *
  1618. //
  1619. // OnLostDevice, OnResetDevice -
  1620. //    Call OnLostDevice() on this object before calling Reset() on the
  1621. //    device, so that this object can release any stateblocks and video
  1622. //    memory resources.  After Reset(), the call OnResetDevice().
  1623. ///////////////////////////////////////////////////////////////////////////
  1624. type
  1625.  
  1626.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXLine);'}
  1627.   {$EXTERNALSYM ID3DXLine}
  1628.   ID3DXLine = interface(IUnknown)
  1629.     ['{72CE4D70-CC40-4143-A896-32E50AD2EF35}']
  1630.     // ID3DXLine
  1631.     function GetDevice(out ppDevice: IDirect3DDevice9): HResult; stdcall;
  1632.  
  1633.     function _Begin: HResult; stdcall;
  1634.  
  1635.     function Draw(pVertexList: PD3DXVector2; dwVertexListCount: DWORD; Color: TD3DColor): HResult; stdcall;
  1636.  
  1637.     function DrawTransform(pVertexList: PD3DXVector3; dwVertexListCount: DWORD;
  1638.       const pTransform: TD3DXMatrix; Color: TD3DColor): HResult; stdcall;
  1639.  
  1640.     function SetPattern(dwPattern: DWORD): HResult; stdcall;
  1641.     function GetPattern: DWORD; stdcall;
  1642.  
  1643.     function SetPatternScale(fPatternScale: Single): HResult; stdcall;
  1644.     function GetPatternScale: Single; stdcall;
  1645.  
  1646.     function SetWidth(fWidth: Single): HResult; stdcall;
  1647.     function GetWidth: Single; stdcall;
  1648.  
  1649.     function SetAntialias(bAntialias: BOOL): HResult; stdcall;
  1650.     function GetAntialias: BOOL; stdcall;
  1651.  
  1652.     function SetGLLines(bGLLines: BOOL): HResult; stdcall;
  1653.     function GetGLLines: BOOL; stdcall;
  1654.  
  1655.     function _End: HResult; stdcall;
  1656.  
  1657.     function OnLostDevice: HResult; stdcall;
  1658.     function OnResetDevice: HResult; stdcall;
  1659.   end;
  1660.  
  1661.  
  1662. function D3DXCreateLine(ppDevice: IDirect3DDevice9;
  1663.   out ppLine: ID3DXLine): HResult; stdcall; external d3dx9coreDLL;
  1664. {$EXTERNALSYM D3DXCreateLine}
  1665.  
  1666.  
  1667.  
  1668.  
  1669.  
  1670. //////////////////////////////////////////////////////////////////////////////
  1671. //
  1672. //  Copyright (c) Microsoft Corporation.  All rights reserved.
  1673. //
  1674. //  File:       d3dx9shader.h
  1675. //  Content:    D3DX Shader APIs
  1676. //
  1677. //////////////////////////////////////////////////////////////////////////////
  1678.  
  1679.  
  1680. //---------------------------------------------------------------------------
  1681. // D3DXTX_VERSION:
  1682. // --------------
  1683. // Version token used to create a procedural texture filler in effects
  1684. // Used by D3DXFill[]TX functions
  1685. //---------------------------------------------------------------------------
  1686. // #define D3DXTX_VERSION(_Major,_Minor) (('T' << 24) | ('X' << 16) | ((_Major) << 8) | (_Minor))
  1687. function D3DXTX_VERSION(_Major, _Minor: Byte): DWORD;
  1688. {$EXTERNALSYM D3DXTX_VERSION}
  1689.  
  1690.  
  1691.  
  1692. //----------------------------------------------------------------------------
  1693. // D3DXSHADER flags:
  1694. // -----------------
  1695. // D3DXSHADER_DEBUG
  1696. //   Insert debug file/line/type/symbol information.
  1697. //
  1698. // D3DXSHADER_SKIPVALIDATION
  1699. //   Do not validate the generated code against known capabilities and
  1700. //   constraints.  This option is only recommended when compiling shaders
  1701. //   you KNOW will work.  (ie. have compiled before without this option.)
  1702. //   Shaders are always validated by D3D before they are set to the device.
  1703. //
  1704. // D3DXSHADER_SKIPOPTIMIZATION (valid for D3DXCompileShader calls only)
  1705. //   Instructs the compiler to skip optimization steps during code generation.
  1706. //   Unless you are trying to isolate a problem in your code, and suspect the
  1707. //   compiler, using this option is not recommended.
  1708. //
  1709. // D3DXSHADER_PACKMATRIX_ROWMAJOR
  1710. //   Unless explicitly specified, matrices will be packed in row-major order
  1711. //   on input and output from the shader.
  1712. //
  1713. // D3DXSHADER_PACKMATRIX_COLUMNMAJOR
  1714. //   Unless explicitly specified, matrices will be packed in column-major
  1715. //   order on input and output from the shader.  This is generally more
  1716. //   efficient, since it allows vector-matrix multiplication to be performed
  1717. //   using a series of dot-products.
  1718. //----------------------------------------------------------------------------
  1719. const
  1720.   D3DXSHADER_DEBUG                    = (1 shl 0);
  1721.   {$EXTERNALSYM D3DXSHADER_DEBUG}
  1722.   D3DXSHADER_SKIPVALIDATION           = (1 shl 2);
  1723.   {$EXTERNALSYM D3DXSHADER_SKIPVALIDATION}
  1724.   D3DXSHADER_SKIPOPTIMIZATION         = (1 shl 3);
  1725.   {$EXTERNALSYM D3DXSHADER_SKIPOPTIMIZATION}
  1726.   D3DXSHADER_PACKMATRIX_ROWMAJOR      = (1 shl 4);
  1727.   {$EXTERNALSYM D3DXSHADER_PACKMATRIX_ROWMAJOR}
  1728.   D3DXSHADER_PACKMATRIX_COLUMNMAJOR   = (1 shl 5);
  1729.   {$EXTERNALSYM D3DXSHADER_PACKMATRIX_COLUMNMAJOR}
  1730.  
  1731.  
  1732.  
  1733. //----------------------------------------------------------------------------
  1734. // D3DXHANDLE:
  1735. // -----------
  1736. // Handle values used to efficiently reference shader and effect parameters.
  1737. // Strings can be used as handles.  However, handles are not always strings.
  1738. //----------------------------------------------------------------------------
  1739.  
  1740. type
  1741.   {$HPPEMIT 'typedef D3DXHANDLE TD3DXHandle;'}
  1742.   {$HPPEMIT 'typedef D3DXHANDLE *PD3DXHandle;'}
  1743.   PD3DXHandle = ^TD3DXHandle;
  1744.   {$EXTERNALSYM PD3DXHandle}
  1745.   TD3DXHandle = {$IFDEF TYPE_IDENTITY}type {$ENDIF}PAnsiChar;
  1746.   {$NODEFINE TD3DXHandle}
  1747.  
  1748.  
  1749. //----------------------------------------------------------------------------
  1750. // D3DXMACRO:
  1751. // ----------
  1752. // Preprocessor macro definition.  The application pass in a NULL-terminated
  1753. // array of this structure to various D3DX APIs.  This enables the application
  1754. // to #define tokens at runtime, before the file is parsed.
  1755. //----------------------------------------------------------------------------
  1756.  
  1757.   PD3DXMacro = ^TD3DXMacro;
  1758.   _D3DXMACRO = packed record
  1759.     Name: PAnsiChar;
  1760.     Definition: PAnsiChar;
  1761.   end;
  1762.   {$EXTERNALSYM _D3DXMACRO}
  1763.   D3DXMACRO = _D3DXMACRO;
  1764.   {$EXTERNALSYM D3DXMACRO}
  1765.   TD3DXMacro = _D3DXMACRO;
  1766.  
  1767.  
  1768. //----------------------------------------------------------------------------
  1769. // D3DXSEMANTIC:
  1770. //----------------------------------------------------------------------------
  1771.  
  1772.   PD3DXSemantic = ^TD3DXSemantic;
  1773.   _D3DXSEMANTIC = packed record
  1774.     Usage: LongWord;
  1775.     UsageIndex: LongWord;
  1776.   end;
  1777.   {$EXTERNALSYM _D3DXSEMANTIC}
  1778.   D3DXSEMANTIC = _D3DXSEMANTIC;
  1779.   {$EXTERNALSYM D3DXSEMANTIC}
  1780.   TD3DXSemantic = _D3DXSEMANTIC;
  1781.  
  1782.  
  1783.  
  1784. //----------------------------------------------------------------------------
  1785. // D3DXFRAGMENT_DESC:
  1786. //----------------------------------------------------------------------------
  1787.  
  1788.   PD3DXFragmentDesc = ^TD3DXFragmentDesc;
  1789.   _D3DXFRAGMENT_DESC = packed record
  1790.     Name: PAnsiChar;
  1791.     Target: DWORD;
  1792.   end;
  1793.   {$EXTERNALSYM _D3DXFRAGMENT_DESC}
  1794.   D3DXFRAGMENT_DESC = _D3DXFRAGMENT_DESC;
  1795.   {$EXTERNALSYM D3DXFRAGMENT_DESC}
  1796.   TD3DXFragmentDesc = _D3DXFRAGMENT_DESC;
  1797.  
  1798.  
  1799. //----------------------------------------------------------------------------
  1800. // D3DXREGISTER_SET:
  1801. //----------------------------------------------------------------------------
  1802.  
  1803.   _D3DXREGISTER_SET = (
  1804.     D3DXRS_BOOL,
  1805.     D3DXRS_INT4,
  1806.     D3DXRS_FLOAT4,
  1807.     D3DXRS_SAMPLER
  1808.   );
  1809.   {$EXTERNALSYM _D3DXREGISTER_SET}
  1810.   D3DXREGISTER_SET = _D3DXREGISTER_SET;
  1811.   {$EXTERNALSYM D3DXREGISTER_SET}
  1812.   TD3DXRegisterSet = _D3DXREGISTER_SET;
  1813.  
  1814.  
  1815. //----------------------------------------------------------------------------
  1816. // D3DXPARAMETER_CLASS:
  1817. //----------------------------------------------------------------------------
  1818.  
  1819.   _D3DXPARAMETER_CLASS = (
  1820.     D3DXPC_SCALAR,
  1821.     D3DXPC_VECTOR,
  1822.     D3DXPC_MATRIX_ROWS,
  1823.     D3DXPC_MATRIX_COLUMNS,
  1824.     D3DXPC_OBJECT,
  1825.     D3DXPC_STRUCT
  1826.   );
  1827.   {$EXTERNALSYM _D3DXPARAMETER_CLASS}
  1828.   D3DXPARAMETER_CLASS = _D3DXPARAMETER_CLASS;
  1829.   {$EXTERNALSYM D3DXPARAMETER_CLASS}
  1830.   TD3DXParameterClass = _D3DXPARAMETER_CLASS;
  1831.  
  1832.  
  1833. //----------------------------------------------------------------------------
  1834. // D3DXPARAMETER_TYPE:
  1835. //----------------------------------------------------------------------------
  1836.  
  1837.   _D3DXPARAMETER_TYPE = (
  1838.     D3DXPT_VOID,
  1839.     D3DXPT_BOOL,
  1840.     D3DXPT_INT,
  1841.     D3DXPT_FLOAT,
  1842.     D3DXPT_STRING,
  1843.     D3DXPT_TEXTURE,
  1844.     D3DXPT_TEXTURE1D,
  1845.     D3DXPT_TEXTURE2D,
  1846.     D3DXPT_TEXTURE3D,
  1847.     D3DXPT_TEXTURECUBE,
  1848.     D3DXPT_SAMPLER,
  1849.     D3DXPT_SAMPLER1D,
  1850.     D3DXPT_SAMPLER2D,
  1851.     D3DXPT_SAMPLER3D,
  1852.     D3DXPT_SAMPLERCUBE,
  1853.     D3DXPT_PIXELSHADER,
  1854.     D3DXPT_VERTEXSHADER,
  1855.     D3DXPT_PIXELFRAGMENT,
  1856.     D3DXPT_VERTEXFRAGMENT
  1857.   );
  1858.   {$EXTERNALSYM _D3DXPARAMETER_TYPE}
  1859.   D3DXPARAMETER_TYPE = _D3DXPARAMETER_TYPE;
  1860.   {$EXTERNALSYM D3DXPARAMETER_TYPE}
  1861.   TD3DXParameterType = _D3DXPARAMETER_TYPE;
  1862.  
  1863.  
  1864.  
  1865. //----------------------------------------------------------------------------
  1866. // D3DXCONSTANTTABLE_DESC:
  1867. //----------------------------------------------------------------------------
  1868.  
  1869.   PD3DXConstantTableDesc = ^TD3DXConstantTableDesc;
  1870.   _D3DXCONSTANTTABLE_DESC = packed record
  1871.     Creator: PAnsiChar;                 // Creator string
  1872.     Version: DWORD;                     // Shader version
  1873.     Constants: LongWord;                // Number of constants
  1874.   end;
  1875.   {$EXTERNALSYM _D3DXCONSTANTTABLE_DESC}
  1876.   D3DXCONSTANTTABLE_DESC = _D3DXCONSTANTTABLE_DESC;
  1877.   {$EXTERNALSYM D3DXCONSTANTTABLE_DESC}
  1878.   TD3DXConstantTableDesc = _D3DXCONSTANTTABLE_DESC;
  1879.  
  1880.  
  1881. //----------------------------------------------------------------------------
  1882. // D3DXCONSTANT_DESC:
  1883. //----------------------------------------------------------------------------
  1884.  
  1885.    PD3DXConstantDesc = ^TD3DXConstantDesc;
  1886.   _D3DXCONSTANT_DESC = packed record
  1887.     Name: PAnsiChar;                    // Constant name
  1888.  
  1889.     RegisterSet: TD3DXRegisterSet;      // Register set
  1890.     RegisterIndex: LongWord;            // Register index
  1891.     RegisterCount: LongWord;            // Number of registers occupied
  1892.  
  1893.     _Class: TD3DXParameterClass;        // Class
  1894.     _Type: TD3DXParameterType;          // Component type
  1895.  
  1896.     Rows: LongWord;                     // Number of rows
  1897.     Columns: LongWord;                  // Number of columns
  1898.     Elements: LongWord;                 // Number of array elements
  1899.     StructMembers: LongWord;            // Number of structure member sub-parameters
  1900.  
  1901.     Bytes: LongWord;                    // Data size, in bytes
  1902.     DefaultValue: Pointer;              // Pointer to default value
  1903.   end;
  1904.   {$EXTERNALSYM _D3DXCONSTANT_DESC}
  1905.   D3DXCONSTANT_DESC = _D3DXCONSTANT_DESC;
  1906.   {$EXTERNALSYM D3DXCONSTANT_DESC}
  1907.    TD3DXConstantDesc = _D3DXCONSTANT_DESC;
  1908.  
  1909.  
  1910.  
  1911. //----------------------------------------------------------------------------
  1912. // ID3DXConstantTable:
  1913. //----------------------------------------------------------------------------
  1914.  
  1915.  
  1916.   PID3DXConstantTable = ^ID3DXConstantTable;
  1917.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXConstantTable);'}
  1918.   {$EXTERNALSYM ID3DXConstantTable}
  1919.   ID3DXConstantTable = interface(ID3DXBuffer)
  1920.     ['{9DCA3190-38B9-4fc3-92E3-39C6DDFB358B}']
  1921.     // Descs
  1922.     function GetDesc(out pDesc: TD3DXConstantTableDesc): HResult; stdcall;
  1923.     function GetConstantDesc(hConstant: TD3DXHandle; pConstantDesc: PD3DXConstantDesc; var pCount: LongWord): HResult; stdcall;
  1924.  
  1925.     // Handle operations
  1926.     function GetConstant(hConstant: TD3DXHandle; Index: LongWord): TD3DXHandle; stdcall;
  1927.     function GetConstantByName(hConstant: TD3DXHandle; pName: PAnsiChar): TD3DXHandle; stdcall;
  1928.     function GetConstantElement(hConstant: TD3DXHandle; Index: LongWord): TD3DXHandle; stdcall;
  1929.  
  1930.     // Set Constants
  1931.     function SetDefaults(pDevice: IDirect3DDevice9): HResult; stdcall;
  1932.     function SetValue(pDevice: IDirect3DDevice9; hConstant: TD3DXHandle; pData: Pointer; Bytes: LongWord): HResult; stdcall;
  1933.     function SetBool(pDevice: IDirect3DDevice9; hConstant: TD3DXHandle; b: BOOL): HResult; stdcall;
  1934.     function SetBoolArray(pDevice: IDirect3DDevice9; hConstant: TD3DXHandle; pb: PBOOL; Count: LongWord): HResult; stdcall;
  1935.     function SetInt(pDevice: IDirect3DDevice9; hConstant: TD3DXHandle; n: Integer): HResult; stdcall;
  1936.     function SetIntArray(pDevice: IDirect3DDevice9; hConstant: TD3DXHandle; pn: PInteger; Count: LongWord): HResult; stdcall;
  1937.     function SetFloat(pDevice: IDirect3DDevice9; hConstant: TD3DXHandle; f: Single): HResult; stdcall;
  1938.     function SetFloatArray(pDevice: IDirect3DDevice9; hConstant: TD3DXHandle; pf: PSingle; Count: LongWord): HResult; stdcall;
  1939.     function SetVector(pDevice: IDirect3DDevice9; hConstant: TD3DXHandle; const pVector: TD3DXVector4): HResult; stdcall;
  1940.     function SetVectorArray(pDevice: IDirect3DDevice9; hConstant: TD3DXHandle; pVector: PD3DXVector4; Count: LongWord): HResult; stdcall;
  1941.     function SetMatrix(pDevice: IDirect3DDevice9; hConstant: TD3DXHandle; const pMatrix: TD3DXMatrix): HResult; stdcall;
  1942.     function SetMatrixArray(pDevice: IDirect3DDevice9; hConstant: TD3DXHandle; pMatrix: PD3DXMatrix; Count: LongWord): HResult; stdcall;
  1943.     function SetMatrixPointerArray(pDevice: IDirect3DDevice9; hConstant: TD3DXHandle; ppMatrix: PPD3DXMatrix; Count: LongWord): HResult; stdcall;
  1944.     function SetMatrixTranspose(pDevice: IDirect3DDevice9; hConstant: TD3DXHandle; const pMatrix: TD3DXMatrix): HResult; stdcall;
  1945.     function SetMatrixTransposeArray(pDevice: IDirect3DDevice9; hConstant: TD3DXHandle; pMatrix: PD3DXMatrix; Count: LongWord): HResult; stdcall;
  1946.     function SetMatrixTransposePointerArray(pDevice: IDirect3DDevice9; hConstant: TD3DXHandle; ppMatrix: PPD3DXMatrix; Count: LongWord): HResult; stdcall;
  1947.   end;
  1948.  
  1949.  
  1950. //----------------------------------------------------------------------------
  1951. // ID3DXFragmentLinker
  1952. //----------------------------------------------------------------------------
  1953.  
  1954.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXFragmentLinker);'}
  1955.   {$EXTERNALSYM ID3DXFragmentLinker}
  1956.   ID3DXFragmentLinker = interface(IUnknown)
  1957.     ['{D59D3777-C973-4a3c-B4B0-2A62CD3D8B40}']
  1958.     // ID3DXFragmentLinker
  1959.  
  1960.     // fragment access and information retrieval functions
  1961.     function GetDevice(out ppDevice: IDirect3DDevice9): HResult; stdcall;
  1962.     function GetNumberOfFragments: LongWord; stdcall;
  1963.  
  1964.     function GetFragmentHandleByIndex(Index: LongWord): TD3DXHandle; stdcall;
  1965.     function GetFragmentHandleByName(Name: PAnsiChar): TD3DXHandle; stdcall;
  1966.     function GetFragmentDesc(Name: TD3DXHandle; out FragDesc: TD3DXFragmentDesc): HResult; stdcall;
  1967.  
  1968.     // add the fragments in the buffer to the linker
  1969.     function AddFragments(Fragments: PDWORD): HResult; stdcall;
  1970.  
  1971.     // Create a buffer containing the fragments.  Suitable for saving to disk
  1972.     function GetAllFragments(out ppBuffer: ID3DXBuffer): HResult; stdcall;
  1973.     function GetFragment(Name: TD3DXHandle; out ppBuffer: ID3DXBuffer): HResult; stdcall;
  1974.  
  1975.     function LinkShader(pTarget: PAnsiChar; Flags: DWORD; rgFragmentHandles: PD3DXHandle; cFragments: LongWord; out ppBuffer: ID3DXBuffer; ppErrorMsgs: PID3DXBuffer): HResult; stdcall;
  1976.     function LinkVertexShader(pTarget: PAnsiChar; Flags: DWORD; rgFragmentHandles: PD3DXHandle; cFragments: LongWord; out pVShader: IDirect3DVertexShader9; ppErrorMsgs: PID3DXBuffer): HResult; stdcall;
  1977.  
  1978.     function ClearCache: HResult; stdcall;
  1979.   end;
  1980.  
  1981.  
  1982. //----------------------------------------------------------------------------
  1983. // D3DXINCLUDE_TYPE:
  1984. //----------------------------------------------------------------------------
  1985. type
  1986.   PD3DXIncludeType = ^TD3DXIncludeType;
  1987.   _D3DXINCLUDE_TYPE = (
  1988.     D3DXINC_LOCAL,
  1989.     D3DXINC_SYSTEM
  1990.   );
  1991.   {$EXTERNALSYM _D3DXINCLUDE_TYPE}
  1992.   D3DXINCLUDE_TYPE = _D3DXINCLUDE_TYPE;
  1993.   {$EXTERNALSYM D3DXINCLUDE_TYPE}
  1994.   TD3DXIncludeType = _D3DXINCLUDE_TYPE;
  1995.  
  1996.  
  1997. //----------------------------------------------------------------------------
  1998. // ID3DXInclude:
  1999. // -------------
  2000. // This interface is intended to be implemented by the application, and can
  2001. // be used by various D3DX APIs.  This enables application-specific handling
  2002. // of #include directives in source files.
  2003. //
  2004. // Open()
  2005. //    Opens an include file.  If successful, it should fill in ppData and
  2006. //    pBytes.  The data pointer returned must remain valid until Close is
  2007. //    subsequently called.
  2008. // Close()
  2009. //    Closes an include file.  If Open was successful, Close is guaranteed
  2010. //    to be called before the API using this interface returns.
  2011. //----------------------------------------------------------------------------
  2012.  
  2013.   PID3DXInclude = ^ID3DXInclude;
  2014.   {$EXTERNALSYM ID3DXInclude}
  2015.   ID3DXInclude = class
  2016.     function Open(IncludeType: TD3DXIncludeType; pFileName: PAnsiChar; pParentData: Pointer; out ppData: Pointer; out pBytes: LongWord): HResult; virtual; stdcall; abstract;
  2017.     function Close(pData: Pointer): HResult; virtual; stdcall; abstract;
  2018.   end;
  2019.  
  2020.  
  2021. //////////////////////////////////////////////////////////////////////////////
  2022. // APIs //////////////////////////////////////////////////////////////////////
  2023. //////////////////////////////////////////////////////////////////////////////
  2024.  
  2025.  
  2026.  
  2027. //----------------------------------------------------------------------------
  2028. // D3DXAssembleShader:
  2029. // -------------------
  2030. // Assembles a shader.
  2031. //
  2032. // Parameters:
  2033. //  pSrcFile
  2034. //      Source file name
  2035. //  hSrcModule
  2036. //      Module handle. if NULL, current module will be used
  2037. //  pSrcResource
  2038. //      Resource name in module
  2039. //  pSrcData
  2040. //      Pointer to source code
  2041. //  SrcDataLen
  2042. //      Size of source code, in bytes
  2043. //  pDefines
  2044. //      Optional NULL-terminated array of preprocessor macro definitions.
  2045. //  pInclude
  2046. //      Optional interface pointer to use for handling #include directives.
  2047. //      If this parameter is NULL, #includes will be honored when assembling
  2048. //      from file, and will error when assembling from resource or memory.
  2049. //  Flags
  2050. //      See D3DXSHADER_xxx flags
  2051. //  ppShader
  2052. //      Returns a buffer containing the created shader.  This buffer contains
  2053. //      the assembled shader code, as well as any embedded debug info.
  2054. //      (See D3DXGetShaderDebugInfo)
  2055. //  ppErrorMsgs
  2056. //      Returns a buffer containing a listing of errors and warnings that were
  2057. //      encountered during assembly.  If you are running in a debugger,
  2058. //      these are the same messages you will see in your debug output.
  2059. //----------------------------------------------------------------------------
  2060.  
  2061. function D3DXAssembleShaderFromFileA(
  2062.   pSrcFile: PAnsiChar;
  2063.   pDefines: PD3DXMacro;
  2064.   pInclude: ID3DXInclude;
  2065.   Flags: DWORD;
  2066.   ppShader: PID3DXBuffer;
  2067.   ppErrorMsgs: PID3DXBuffer): HResult; stdcall; external d3dx9shaderDLL name 'D3DXAssembleShaderFromFileA';
  2068. {$EXTERNALSYM D3DXAssembleShaderFromFileA}
  2069.  
  2070. function D3DXAssembleShaderFromFileW(
  2071.   pSrcFile: PWideChar;
  2072.   pDefines: PD3DXMacro;
  2073.   pInclude: ID3DXInclude;
  2074.   Flags: DWORD;
  2075.   ppShader: PID3DXBuffer;
  2076.   ppErrorMsgs: PID3DXBuffer): HResult; stdcall; external d3dx9shaderDLL name 'D3DXAssembleShaderFromFileW';
  2077. {$EXTERNALSYM D3DXAssembleShaderFromFileW}
  2078.  
  2079. function D3DXAssembleShaderFromFile(
  2080.   pSrcFile: PChar;
  2081.   pDefines: PD3DXMacro;
  2082.   pInclude: ID3DXInclude;
  2083.   Flags: DWORD;
  2084.   ppShader: PID3DXBuffer;
  2085.   ppErrorMsgs: PID3DXBuffer): HResult; stdcall; external d3dx9shaderDLL name 'D3DXAssembleShaderFromFileA';
  2086. {$EXTERNALSYM D3DXAssembleShaderFromFile}
  2087.  
  2088.  
  2089. function D3DXAssembleShaderFromResourceA(
  2090.   hSrcModule: HModule;
  2091.   pSrcResource: PAnsiChar;
  2092.   pDefines: PD3DXMacro;
  2093.   pInclude: ID3DXInclude;
  2094.   Flags: DWord;
  2095.   ppShader: PID3DXBuffer;
  2096.   ppErrorMsgs: PID3DXBuffer): HResult; stdcall; external d3dx9shaderDLL name 'D3DXAssembleShaderFromResourceA';
  2097. {$EXTERNALSYM D3DXAssembleShaderFromResourceA}
  2098.  
  2099. function D3DXAssembleShaderFromResourceW(
  2100.   hSrcModule: HModule;
  2101.   pSrcResource: PWideChar;
  2102.   pDefines: PD3DXMacro;
  2103.   pInclude: ID3DXInclude;
  2104.   Flags: DWord;
  2105.   ppShader: PID3DXBuffer;
  2106.   ppErrorMsgs: PID3DXBuffer): HResult; stdcall; external d3dx9shaderDLL name 'D3DXAssembleShaderFromResourceW';
  2107. {$EXTERNALSYM D3DXAssembleShaderFromResourceW}
  2108.  
  2109. function D3DXAssembleShaderFromResource(
  2110.   hSrcModule: HModule;
  2111.   pSrcResource: PChar;
  2112.   pDefines: PD3DXMacro;
  2113.   pInclude: ID3DXInclude;
  2114.   Flags: DWord;
  2115.   ppShader: PID3DXBuffer;
  2116.   ppErrorMsgs: PID3DXBuffer): HResult; stdcall; external d3dx9shaderDLL name 'D3DXAssembleShaderFromResourceA';
  2117. {$EXTERNALSYM D3DXAssembleShaderFromResource}
  2118.  
  2119.  
  2120. function D3DXAssembleShader(
  2121.   pSrcData: PAnsiChar;
  2122.   SrcDataLen: LongWord;
  2123.   pDefines: PD3DXMacro;
  2124.   pInclude: ID3DXInclude;
  2125.   Flags: DWord;
  2126.   ppShader: PID3DXBuffer;
  2127.   ppErrorMsgs: PID3DXBuffer): HResult; stdcall; external d3dx9shaderDLL;
  2128. {$EXTERNALSYM D3DXAssembleShader}
  2129.  
  2130.  
  2131.   
  2132. //----------------------------------------------------------------------------
  2133. // D3DXCompileShader:
  2134. // ------------------
  2135. // Compiles a shader.
  2136. //
  2137. // Parameters:
  2138. //  pSrcFile
  2139. //      Source file name.
  2140. //  hSrcModule
  2141. //      Module handle. if NULL, current module will be used.
  2142. //  pSrcResource
  2143. //      Resource name in module.
  2144. //  pSrcData
  2145. //      Pointer to source code.
  2146. //  SrcDataLen
  2147. //      Size of source code, in bytes.
  2148. //  pDefines
  2149. //      Optional NULL-terminated array of preprocessor macro definitions.
  2150. //  pInclude
  2151. //      Optional interface pointer to use for handling #include directives.
  2152. //      If this parameter is NULL, #includes will be honored when compiling
  2153. //      from file, and will error when compiling from resource or memory.
  2154. //  pFunctionName
  2155. //      Name of the entrypoint function where execution should begin.
  2156. //  pTarget
  2157. //      Instruction set to be used when generating code.  Currently supported
  2158. //      targets are "vs_1_1", "vs_2_0", "vs_2_sw", "ps_1_1", "ps_1_2", "ps_1_3", 
  2159. //      "ps_1_4", "ps_2_0", "ps_2_sw", "tx_1_0"
  2160. //  Flags
  2161. //      See D3DXSHADER_xxx flags.
  2162. //  ppShader
  2163. //      Returns a buffer containing the created shader.  This buffer contains
  2164. //      the compiled shader code, as well as any embedded debug and symbol
  2165. //      table info.  (See D3DXGetShaderDebugInfo, D3DXGetShaderConstantTable)
  2166. //  ppErrorMsgs
  2167. //      Returns a buffer containing a listing of errors and warnings that were
  2168. //      encountered during the compile.  If you are running in a debugger,
  2169. //      these are the same messages you will see in your debug output.
  2170. //  ppConstantTable
  2171. //      Returns a ID3DXConstantTable object which can be used to set
  2172. //      shader constants to the device.  Alternatively, an application can
  2173. //      parse the D3DXSHADER_CONSTANTTABLE block embedded as a comment within
  2174. //      the shader.
  2175. //----------------------------------------------------------------------------
  2176.  
  2177. function D3DXCompileShaderFromFileA(
  2178.   pSrcFile: PAnsiChar;
  2179.   pDefines: PD3DXMacro;
  2180.   pInclude: ID3DXInclude;
  2181.   pFunctionName: PAnsiChar;
  2182.   pTarget: PAnsiChar;
  2183.   Flags: DWORD;
  2184.   ppShader: PID3DXBuffer;
  2185.   ppErrorMsgs: PID3DXBuffer;
  2186.   ppConstantTable: PID3DXConstantTable): HResult; stdcall; external d3dx9shaderDLL name 'D3DXCompileShaderFromFileA';
  2187. {$EXTERNALSYM D3DXCompileShaderFromFileA}
  2188.  
  2189. function D3DXCompileShaderFromFileW(
  2190.   pSrcFile: PWideChar;
  2191.   pDefines: PD3DXMacro;
  2192.   pInclude: ID3DXInclude;
  2193.   pFunctionName: PAnsiChar;
  2194.   pTarget: PAnsiChar;
  2195.   Flags: DWORD;
  2196.   ppShader: PID3DXBuffer;
  2197.   ppErrorMsgs: PID3DXBuffer;
  2198.   ppConstantTable: PID3DXConstantTable): HResult; stdcall; external d3dx9shaderDLL name 'D3DXCompileShaderFromFileW';
  2199. {$EXTERNALSYM D3DXCompileShaderFromFileW}
  2200.  
  2201. function D3DXCompileShaderFromFile(
  2202.   pSrcFile: PChar;
  2203.   pDefines: PD3DXMacro;
  2204.   pInclude: ID3DXInclude;
  2205.   pFunctionName: PAnsiChar;
  2206.   pTarget: PAnsiChar;
  2207.   Flags: DWORD;
  2208.   ppShader: PID3DXBuffer;
  2209.   ppErrorMsgs: PID3DXBuffer;
  2210.   ppConstantTable: PID3DXConstantTable): HResult; stdcall; external d3dx9shaderDLL name 'D3DXCompileShaderFromFileA';
  2211. {$EXTERNALSYM D3DXCompileShaderFromFile}
  2212.  
  2213.  
  2214. function D3DXCompileShaderFromResourceA(
  2215.   hSrcModule: HModule;
  2216.   pSrcResource: PAnsiChar;
  2217.   pDefines: PD3DXMacro;
  2218.   pInclude: ID3DXInclude;
  2219.   pFunctionName: PAnsiChar;
  2220.   pTarget: PAnsiChar;
  2221.   Flags: DWORD;
  2222.   ppShader: PID3DXBuffer;
  2223.   ppErrorMsgs: PID3DXBuffer;
  2224.   ppConstantTable: PID3DXConstantTable): HResult; stdcall; external d3dx9shaderDLL name 'D3DXCompileShaderFromResourceA';
  2225. {$EXTERNALSYM D3DXCompileShaderFromResourceA}
  2226.  
  2227. function D3DXCompileShaderFromResourceW(
  2228.   hSrcModule: HModule;
  2229.   pSrcResource: PWideChar;
  2230.   pDefines: PD3DXMacro;
  2231.   pInclude: ID3DXInclude;
  2232.   pFunctionName: PAnsiChar;
  2233.   pTarget: PAnsiChar;
  2234.   Flags: DWORD;
  2235.   ppShader: PID3DXBuffer;
  2236.   ppErrorMsgs: PID3DXBuffer;
  2237.   ppConstantTable: PID3DXConstantTable): HResult; stdcall; external d3dx9shaderDLL name 'D3DXCompileShaderFromResourceW';
  2238. {$EXTERNALSYM D3DXCompileShaderFromResourceW}
  2239.  
  2240. function D3DXCompileShaderFromResource(
  2241.   hSrcModule: HModule;
  2242.   pSrcResource: PChar;
  2243.   pDefines: PD3DXMacro;
  2244.   pInclude: ID3DXInclude;
  2245.   pFunctionName: PAnsiChar;
  2246.   pTarget: PAnsiChar;
  2247.   Flags: DWORD;
  2248.   ppShader: PID3DXBuffer;
  2249.   ppErrorMsgs: PID3DXBuffer;
  2250.   ppConstantTable: PID3DXConstantTable): HResult; stdcall; external d3dx9shaderDLL name 'D3DXCompileShaderFromResourceA';
  2251. {$EXTERNALSYM D3DXCompileShaderFromResource}
  2252.  
  2253.  
  2254. function D3DXCompileShader(
  2255.   pSrcData: PAnsiChar;
  2256.   SrcDataLen: LongWord;
  2257.   pDefines: PD3DXMacro;
  2258.   pInclude: ID3DXInclude;
  2259.   pFunctionName: PAnsiChar;
  2260.   pTarget: PAnsiChar;
  2261.   Flags: DWORD;
  2262.   ppShader: PID3DXBuffer;
  2263.   ppErrorMsgs: PID3DXBuffer;
  2264.   ppConstantTable: PID3DXConstantTable): HResult; stdcall; external d3dx9shaderDLL;
  2265. {$EXTERNALSYM D3DXCompileShader}
  2266.  
  2267. //----------------------------------------------------------------------------
  2268. // D3DXFindShaderComment:
  2269. // ----------------------
  2270. // Searches through a shader for a particular comment, denoted by a FourCC in
  2271. // the first DWORD of the comment.  If the comment is not found, and no other
  2272. // error has occurred, S_FALSE is returned.
  2273. //
  2274. // Parameters:
  2275. //  pFunction
  2276. //      Pointer to the function DWORD stream
  2277. //  FourCC
  2278. //      FourCC used to identify the desired comment block.
  2279. //  ppData
  2280. //      Returns a pointer to the comment data (not including comment token
  2281. //      and FourCC).  Can be NULL.
  2282. //  pSizeInBytes
  2283. //      Returns the size of the comment data in bytes.  Can be NULL.
  2284. //----------------------------------------------------------------------------
  2285.  
  2286. function D3DXFindShaderComment(
  2287.   pFunction: PDWORD;
  2288.   FourCC: DWORD;
  2289.   ppData: PPointer;
  2290.   pSizeInBytes: PLongWord): HResult; stdcall; external d3dx9shaderDLL;
  2291. {$EXTERNALSYM D3DXFindShaderComment}
  2292.  
  2293.  
  2294. //----------------------------------------------------------------------------
  2295. // D3DXGetShaderSemantics:
  2296. // -----------------------
  2297. // Gets semantics for all input elements referenced inside a given shader.
  2298. //
  2299. // Parameters:
  2300. //  pFunction
  2301. //      Pointer to the function DWORD stream
  2302. //  pSemantics
  2303. //      Pointer to an array of D3DXSEMANTIC structures.  The function will
  2304. //      fill this array with the semantics for each input element referenced
  2305. //      inside the shader.  This array is assumed to contain at least
  2306. //      MAXD3DDECLLENGTH elements.
  2307. //  pCount
  2308. //      Returns the number of elements referenced by the shader
  2309. //----------------------------------------------------------------------------
  2310.  
  2311. function D3DXGetShaderInputSemantics(
  2312.   pFunction: PDWORD;
  2313.   pSemantics: PD3DXSemantic;
  2314.   pCount: PLongWord): HResult; stdcall; external d3dx9shaderDLL;
  2315. {$EXTERNALSYM D3DXGetShaderInputSemantics}
  2316.  
  2317. function D3DXGetShaderOutputSemantics(
  2318.   pFunction: PDWORD;
  2319.   pSemantics: PD3DXSemantic;
  2320.   pCount: PLongWord): HResult; stdcall; external d3dx9shaderDLL;
  2321. {$EXTERNALSYM D3DXGetShaderOutputSemantics}
  2322.  
  2323.  
  2324. //----------------------------------------------------------------------------
  2325. // D3DXGetShaderSamplers:
  2326. // ----------------------
  2327. // Gets semantics for all input elements referenced inside a given shader.
  2328. //
  2329. // pFunction
  2330. //      Pointer to the function DWORD stream
  2331. // pSamplers
  2332. //      Pointer to an array of LPCSTRs.  The function will fill this array
  2333. //      with pointers to the sampler names contained within pFunction, for
  2334. //      each sampler referenced inside the shader.  This array is assumed to
  2335. //      contain at least 16 elements.
  2336. // pCount
  2337. //      Returns the number of samplers referenced by the shader
  2338. //----------------------------------------------------------------------------
  2339.  
  2340. function D3DXGetShaderSamplers(
  2341.   pFunction: PDWORD;
  2342.   pSamplers: PPAnsiChar;
  2343.   pCount: PLongWord): HResult; stdcall; external d3dx9shaderDLL;
  2344. {$EXTERNALSYM D3DXGetShaderSamplers}
  2345.  
  2346.  
  2347. //----------------------------------------------------------------------------
  2348. // D3DXGetShaderConstantTable:
  2349. // ---------------------------
  2350. // Gets shader constant table embedded inside shader.  A constant table is
  2351. // generated by D3DXAssembleShader and D3DXCompileShader, and is embedded in
  2352. // the body of the shader.
  2353. //
  2354. // Parameters:
  2355. //  pFunction
  2356. //      Pointer to the function DWORD stream
  2357. //  ppConstantTable
  2358. //      Returns a ID3DXConstantTable object which can be used to set
  2359. //      shader constants to the device.  Alternatively, an application can
  2360. //      parse the D3DXSHADER_CONSTANTTABLE block embedded as a comment within
  2361. //      the shader.
  2362. //----------------------------------------------------------------------------
  2363.  
  2364. function D3DXGetShaderConstantTable(
  2365.   pFunction: PDWORD;
  2366.   out ppConstantTable: ID3DXConstantTable): HResult; stdcall; external d3dx9shaderDLL;
  2367. {$EXTERNALSYM D3DXGetShaderConstantTable}
  2368.  
  2369.  
  2370. //----------------------------------------------------------------------------
  2371. // D3DXGetShaderDebugInfo:
  2372. // -----------------------
  2373. // Gets shader debug info.  Debug info is generated D3DXAssembleShader and
  2374. // D3DXCompileShader and is embedded the body of the shader.
  2375. //
  2376. // Parameters:
  2377. //  pFunction
  2378. //      Pointer to the function DWORD stream
  2379. //  ppDebugInfo
  2380. //      Buffer used to return debug info.  For information about the layout
  2381. //      of this buffer, see definition of D3DXSHADER_DEBUGINFO above.
  2382. //----------------------------------------------------------------------------
  2383.  
  2384. function D3DXGetShaderDebugInfo(
  2385.   pFunction: PDWORD;
  2386.   out ppDebugInfo: ID3DXBuffer): HResult; stdcall; external d3dx9shaderDLL;
  2387. {$EXTERNALSYM D3DXGetShaderDebugInfo}
  2388.  
  2389.  
  2390.  
  2391. //----------------------------------------------------------------------------
  2392. // D3DXGatherFragments:
  2393. // -------------------
  2394. // Assembles shader fragments into a buffer to be passed to a fragment linker.
  2395. //   will generate shader fragments for all fragments in the file
  2396. //
  2397. // Parameters:
  2398. //  pSrcFile
  2399. //      Source file name
  2400. //  hSrcModule
  2401. //      Module handle. if NULL, current module will be used
  2402. //  pSrcResource
  2403. //      Resource name in module
  2404. //  pSrcData
  2405. //      Pointer to source code
  2406. //  SrcDataLen
  2407. //      Size of source code, in bytes
  2408. //  pDefines
  2409. //      Optional NULL-terminated array of preprocessor macro definitions.
  2410. //  pInclude
  2411. //      Optional interface pointer to use for handling #include directives.
  2412. //      If this parameter is NULL, #includes will be honored when assembling
  2413. //      from file, and will error when assembling from resource or memory.
  2414. //  Flags
  2415. //      See D3DXSHADER_xxx flags
  2416. //  ppShader
  2417. //      Returns a buffer containing the created shader fragments.  This buffer contains
  2418. //      the assembled shader code, as well as any embedded debug info.
  2419. //  ppErrorMsgs
  2420. //      Returns a buffer containing a listing of errors and warnings that were
  2421. //      encountered during assembly.  If you are running in a debugger,
  2422. //      these are the same messages you will see in your debug output.
  2423. //----------------------------------------------------------------------------
  2424.  
  2425.  
  2426. function D3DXGatherFragmentsFromFileA(
  2427.   pSrcFile: PAnsiChar;
  2428.   pDefines: PD3DXMacro;
  2429.   pInclude: ID3DXInclude;
  2430.   Flags: DWORD;
  2431.   ppShader: PID3DXBuffer;
  2432.   ppErrorMsgs: PID3DXBuffer): HResult; stdcall; external d3dx9shaderDLL name 'D3DXGatherFragmentsFromFileA';
  2433. {$EXTERNALSYM D3DXGatherFragmentsFromFileA}
  2434.  
  2435. function D3DXGatherFragmentsFromFileW(
  2436.   pSrcFile: PWideChar;
  2437.   pDefines: PD3DXMacro;
  2438.   pInclude: ID3DXInclude;
  2439.   Flags: DWORD;
  2440.   ppShader: PID3DXBuffer;
  2441.   ppErrorMsgs: PID3DXBuffer): HResult; stdcall; external d3dx9shaderDLL name 'D3DXGatherFragmentsFromFileW';
  2442. {$EXTERNALSYM D3DXGatherFragmentsFromFileW}
  2443.  
  2444. function D3DXGatherFragmentsFromFile(
  2445.   pSrcFile: PChar;
  2446.   pDefines: PD3DXMacro;
  2447.   pInclude: ID3DXInclude;
  2448.   Flags: DWORD;
  2449.   ppShader: PID3DXBuffer;
  2450.   ppErrorMsgs: PID3DXBuffer): HResult; stdcall; external d3dx9shaderDLL name 'D3DXGatherFragmentsFromFileA';
  2451. {$EXTERNALSYM D3DXGatherFragmentsFromFile}
  2452.  
  2453.  
  2454. function D3DXGatherFragmentsFromResourceA(
  2455.   hSrcModule: HModule;
  2456.   pSrcResource: PAnsiChar;
  2457.   pDefines: PD3DXMacro;
  2458.   pInclude: ID3DXInclude;
  2459.   Flags: DWord;
  2460.   ppShader: PID3DXBuffer;
  2461.   ppErrorMsgs: PID3DXBuffer): HResult; stdcall; external d3dx9shaderDLL name 'D3DXGatherFragmentsFromResourceA';
  2462. {$EXTERNALSYM D3DXGatherFragmentsFromResourceA}
  2463.  
  2464. function D3DXGatherFragmentsFromResourceW(
  2465.   hSrcModule: HModule;
  2466.   pSrcResource: PWideChar;
  2467.   pDefines: PD3DXMacro;
  2468.   pInclude: ID3DXInclude;
  2469.   Flags: DWord;
  2470.   ppShader: PID3DXBuffer;
  2471.   ppErrorMsgs: PID3DXBuffer): HResult; stdcall; external d3dx9shaderDLL name 'D3DXGatherFragmentsFromResourceW';
  2472. {$EXTERNALSYM D3DXGatherFragmentsFromResourceW}
  2473.  
  2474. function D3DXGatherFragmentsFromResource(
  2475.   hSrcModule: HModule;
  2476.   pSrcResource: PChar;
  2477.   pDefines: PD3DXMacro;
  2478.   pInclude: ID3DXInclude;
  2479.   Flags: DWord;
  2480.   ppShader: PID3DXBuffer;
  2481.   ppErrorMsgs: PID3DXBuffer): HResult; stdcall; external d3dx9shaderDLL name 'D3DXGatherFragmentsFromResourceA';
  2482. {$EXTERNALSYM D3DXGatherFragmentsFromResource}
  2483.  
  2484.  
  2485. function D3DXGatherFragments(
  2486.   pSrcData: PAnsiChar;
  2487.   SrcDataLen: LongWord;
  2488.   pDefines: PD3DXMacro;
  2489.   pInclude: ID3DXInclude;
  2490.   Flags: DWord;
  2491.   ppShader: PID3DXBuffer;
  2492.   ppErrorMsgs: PID3DXBuffer): HResult; stdcall; external d3dx9shaderDLL;
  2493. {$EXTERNALSYM D3DXGatherFragments}
  2494.  
  2495.  
  2496. //----------------------------------------------------------------------------
  2497. // D3DXCreateFragmentLinker:
  2498. // -------------------------
  2499. // Creates a fragment linker with a given cache size.  The interface returned
  2500. // can be used to link together shader fragments.  (both HLSL & ASM fragements)
  2501. //
  2502. // Parameters:
  2503. //  pDevice
  2504. //      Pointer of the device on which to create the effect
  2505. //  ShaderCacheSize
  2506. //      Size of the shader cache
  2507. //  ppFragmentLinker
  2508. //      pointer to a memory location to put the created interface pointer
  2509. //
  2510. //----------------------------------------------------------------------------
  2511.  
  2512. function D3DXCreateFragmentLinker(
  2513.   pDevice: IDirect3DDevice9;
  2514.   ShaderCacheSize: LongWord;
  2515.   out ppFragmentLinker: ID3DXFragmentLinker): HResult; stdcall; external d3dx9shaderDLL;
  2516. {$EXTERNALSYM D3DXCreateFragmentLinker}
  2517.  
  2518.  
  2519.  
  2520. //////////////////////////////////////////////////////////////////////////////
  2521. // Shader comment block layouts //////////////////////////////////////////////
  2522. //////////////////////////////////////////////////////////////////////////////
  2523.  
  2524. //----------------------------------------------------------------------------
  2525. // D3DXSHADER_CONSTANTTABLE:
  2526. // -------------------------
  2527. // Shader constant information; included as an CTAB comment block inside
  2528. // shaders.  All offsets are BYTE offsets from start of CONSTANTTABLE struct.
  2529. // Entries in the table are sorted by Name in ascending order.
  2530. //----------------------------------------------------------------------------
  2531.  
  2532. type
  2533.   PD3DXShaderConstantTable = ^TD3DXShaderConstantTable;
  2534.   _D3DXSHADER_CONSTANTTABLE = packed record
  2535.     Size: DWORD;             // sizeof(D3DXSHADER_CONSTANTTABLE)
  2536.     Creator: DWORD;          // LPCSTR offset
  2537.     Version: DWORD;          // shader version
  2538.     Constants: DWORD;        // number of constants
  2539.     ConstantInfo: DWORD;     // D3DXSHADER_CONSTANTINFO[Constants] offset
  2540.   end;
  2541.   {$EXTERNALSYM _D3DXSHADER_CONSTANTTABLE}
  2542.   D3DXSHADER_CONSTANTTABLE = _D3DXSHADER_CONSTANTTABLE;
  2543.   {$EXTERNALSYM D3DXSHADER_CONSTANTTABLE}
  2544.   TD3DXShaderConstantTable = _D3DXSHADER_CONSTANTTABLE;
  2545.  
  2546.  
  2547.   PD3DXShaderConstantInfo = ^TD3DXShaderConstantInfo;
  2548.   _D3DXSHADER_CONSTANTINFO = packed record
  2549.     Name: DWORD;             // LPCSTR offset
  2550.     RegisterSet: Word;       // D3DXREGISTER_SET
  2551.     RegisterIndex: Word;     // register number
  2552.     RegisterCount: Word;     // number of registers
  2553.     Reserved: Word;          // reserved
  2554.     TypeInfo: DWORD;         // D3DXSHADER_TYPEINFO offset
  2555.     DefaultValue: DWORD;     // offset of default value
  2556.   end;
  2557.   {$EXTERNALSYM _D3DXSHADER_CONSTANTINFO}
  2558.   D3DXSHADER_CONSTANTINFO = _D3DXSHADER_CONSTANTINFO;
  2559.   {$EXTERNALSYM D3DXSHADER_CONSTANTINFO}
  2560.   TD3DXShaderConstantInfo = _D3DXSHADER_CONSTANTINFO;
  2561.  
  2562.  
  2563.   PD3DXShaderTypeInfo = ^TD3DXShaderTypeInfo;
  2564.   _D3DXSHADER_TYPEINFO = packed record
  2565.     _Class: Word;            // D3DXPARAMETER_CLASS
  2566.     _Type: Word;             // D3DXPARAMETER_TYPE
  2567.     Rows: Word;              // number of rows (matrices)
  2568.     Columns: Word;           // number of columns (vectors and matrices)
  2569.     Elements: Word;          // array dimension
  2570.     StructMembers: Word;     // number of struct members
  2571.     StructMemberInfo: DWORD; // D3DXSHADER_STRUCTMEMBERINFO[Members] offset
  2572.   end;
  2573.   {$EXTERNALSYM _D3DXSHADER_TYPEINFO}
  2574.   D3DXSHADER_TYPEINFO = _D3DXSHADER_TYPEINFO;
  2575.   {$EXTERNALSYM D3DXSHADER_TYPEINFO}
  2576.   TD3DXShaderTypeInfo = _D3DXSHADER_TYPEINFO;
  2577.  
  2578.  
  2579.   PD3DXShaderStructMemberInfo = ^TD3DXShaderStructMemberInfo;
  2580.   _D3DXSHADER_STRUCTMEMBERINFO = packed record
  2581.     Name: DWORD;             // LPCSTR offset
  2582.     TypeInfo: DWORD;         // D3DXSHADER_TYPEINFO offset
  2583.   end;
  2584.   {$EXTERNALSYM _D3DXSHADER_STRUCTMEMBERINFO}
  2585.   D3DXSHADER_STRUCTMEMBERINFO = _D3DXSHADER_STRUCTMEMBERINFO;
  2586.   {$EXTERNALSYM D3DXSHADER_STRUCTMEMBERINFO}
  2587.   TD3DXShaderStructMemberInfo = _D3DXSHADER_STRUCTMEMBERINFO;
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594. //////////////////////////////////////////////////////////////////////////////
  2595. //
  2596. //  Copyright (c) Microsoft Corporation.  All rights reserved.
  2597. //
  2598. //  File:       d3dx9effect.h
  2599. //  Content:    D3DX effect types and Shaders
  2600. //
  2601. //////////////////////////////////////////////////////////////////////////////
  2602.  
  2603.  
  2604. //----------------------------------------------------------------------------
  2605. // D3DXFX_DONOTSAVESTATE
  2606. //   This flag is used as a parameter to ID3DXEffect::Begin().  When this flag
  2607. //   is specified, device state is not saved and restored in Begin/End.
  2608. // D3DXFX_DONOTSAVESHADERSTATE
  2609. //   This flag is used as a parameter to ID3DXEffect::Begin().  When this flag
  2610. //   is specified, shader device state is not saved and restored in Begin/End.
  2611. //   This includes pixel/vertex shaders and shader constants
  2612. //----------------------------------------------------------------------------
  2613. const
  2614.   D3DXFX_DONOTSAVESTATE         = (1 shl 0);
  2615.   {$EXTERNALSYM D3DXFX_DONOTSAVESTATE}
  2616.   D3DXFX_DONOTSAVESHADERSTATE   = (1 shl 1);
  2617.   {$EXTERNALSYM D3DXFX_DONOTSAVESHADERSTATE}
  2618.  
  2619.  
  2620. //----------------------------------------------------------------------------
  2621. // D3DX_PARAMETER_SHARED
  2622. //   Indicates that the value of a parameter will be shared with all effects
  2623. //   which share the same namespace.  Changing the value in one effect will
  2624. //   change it in all.
  2625. //
  2626. // D3DX_PARAMETER_LITERAL
  2627. //   Indicates that the value of this parameter can be treated as literal.
  2628. //   Literal parameters can be marked when the effect is compiled, and their
  2629. //   cannot be changed after the effect is compiled.  Shared parameters cannot
  2630. //   be literal.
  2631. //----------------------------------------------------------------------------
  2632. const
  2633.   D3DX_PARAMETER_SHARED       = (1 shl 0);
  2634.   {$EXTERNALSYM D3DX_PARAMETER_SHARED}
  2635.   D3DX_PARAMETER_LITERAL      = (1 shl 1);
  2636.   {$EXTERNALSYM D3DX_PARAMETER_LITERAL}
  2637.   D3DX_PARAMETER_ANNOTATION   = (1 shl 2);
  2638.   {$EXTERNALSYM D3DX_PARAMETER_ANNOTATION}
  2639.  
  2640.  
  2641. //----------------------------------------------------------------------------
  2642. // D3DXEFFECT_DESC:
  2643. //----------------------------------------------------------------------------
  2644.  
  2645. type
  2646.   _D3DXEFFECT_DESC = packed record
  2647.     Creator: PAnsiChar;                 // Creator string
  2648.     Parameters: LongWord;               // Number of parameters
  2649.     Techniques: LongWord;               // Number of techniques
  2650.     Functions: LongWord;                // Number of function entrypoints
  2651.   end;
  2652.   {$EXTERNALSYM _D3DXEFFECT_DESC}
  2653.   D3DXEFFECT_DESC = _D3DXEFFECT_DESC;
  2654.   {$EXTERNALSYM D3DXEFFECT_DESC}
  2655.   TD3DXEffectDesc = _D3DXEFFECT_DESC;
  2656.  
  2657.  
  2658. //----------------------------------------------------------------------------
  2659. // D3DXPARAMETER_DESC:
  2660. //----------------------------------------------------------------------------
  2661.  
  2662.   PD3DXParameterDesc = ^TD3DXParameterDesc;
  2663.   _D3DXPARAMETER_DESC = packed record
  2664.     Name: PAnsiChar;                    // Parameter name
  2665.     Semantic: PAnsiChar;                // Parameter semantic
  2666.     _Class: TD3DXParameterClass;        // Class
  2667.     _Type: TD3DXParameterType;          // Component type
  2668.     Rows: LongWord;                     // Number of rows
  2669.     Columns: LongWord;                  // Number of columns
  2670.     Elements: LongWord;                 // Number of array elements
  2671.     Annotations: LongWord;              // Number of annotations
  2672.     StructMembers: LongWord;            // Number of structure member sub-parameters
  2673.     Flags: DWORD;                       // D3DX_PARAMETER_* flags
  2674.     Bytes: LongWord;                    // Parameter size, in bytes
  2675.   end;
  2676.   {$EXTERNALSYM _D3DXPARAMETER_DESC}
  2677.   D3DXPARAMETER_DESC = _D3DXPARAMETER_DESC;
  2678.   {$EXTERNALSYM D3DXPARAMETER_DESC}
  2679.   TD3DXParameterDesc = _D3DXPARAMETER_DESC;
  2680.  
  2681.  
  2682. //----------------------------------------------------------------------------
  2683. // D3DXTECHNIQUE_DESC:
  2684. //----------------------------------------------------------------------------
  2685.  
  2686.   PD3DXTechniqueDesc = ^TD3DXTechniqueDesc;
  2687.   _D3DXTECHNIQUE_DESC = packed record
  2688.     Name: PAnsiChar;                    // Technique name
  2689.     Passes: LongWord;                   // Number of passes
  2690.     Annotations: LongWord;              // Number of annotations
  2691.   end;
  2692.   {$EXTERNALSYM _D3DXTECHNIQUE_DESC}
  2693.   D3DXTECHNIQUE_DESC = _D3DXTECHNIQUE_DESC;
  2694.   {$EXTERNALSYM D3DXTECHNIQUE_DESC}
  2695.   TD3DXTechniqueDesc = _D3DXTECHNIQUE_DESC;
  2696.  
  2697.  
  2698. //----------------------------------------------------------------------------
  2699. // D3DXPASS_DESC:
  2700. //----------------------------------------------------------------------------
  2701.  
  2702.   PD3DXPassDesc = ^TD3DXPassDesc;
  2703.   _D3DXPASS_DESC = packed record
  2704.     Name: PAnsiChar;                    // Pass name
  2705.     Annotations: LongWord;              // Number of annotations
  2706.  
  2707.     VSVersion: DWORD;                   // Vertex shader version (0 in case of NULL shader)
  2708.     PSVersion: DWORD;                   // Pixel shader version (0 in case of NULL shader)
  2709.  
  2710.     VSSemanticsUsed: LongWord;
  2711.     VSSemantics: array [0..MAXD3DDECLLENGTH-1] of TD3DXSemantic;
  2712.  
  2713.     PSSemanticsUsed: LongWord;
  2714.     PSSemantics: array [0..MAXD3DDECLLENGTH-1]of TD3DXSemantic;
  2715.  
  2716.     PSSamplersUsed: LongWord;
  2717.     PSSamplers: array [0..15] of PAnsiChar;
  2718.   end;
  2719.   {$EXTERNALSYM _D3DXPASS_DESC}
  2720.   D3DXPASS_DESC = _D3DXPASS_DESC;
  2721.   {$EXTERNALSYM D3DXPASS_DESC}
  2722.   TD3DXPassDesc = _D3DXPASS_DESC;
  2723.  
  2724.  
  2725. //----------------------------------------------------------------------------
  2726. // D3DXFUNCTION_DESC:
  2727. //----------------------------------------------------------------------------
  2728.  
  2729.   PD3DXFunctionDesc = ^TD3DXFunctionDesc;
  2730.   _D3DXFUNCTION_DESC = packed record
  2731.     Name: PAnsiChar;                    // Function name
  2732.     Annotations: LongWord;              // Number of annotations
  2733.   end;
  2734.   {$EXTERNALSYM _D3DXFUNCTION_DESC}
  2735.   D3DXFUNCTION_DESC = _D3DXFUNCTION_DESC;
  2736.   {$EXTERNALSYM D3DXFUNCTION_DESC}
  2737.   TD3DXFunctionDesc = _D3DXFUNCTION_DESC;
  2738.  
  2739.  
  2740.  
  2741. //////////////////////////////////////////////////////////////////////////////
  2742. // ID3DXEffectPool ///////////////////////////////////////////////////////////
  2743. //////////////////////////////////////////////////////////////////////////////
  2744.  
  2745.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXEffectPool);'}
  2746.   {$EXTERNALSYM ID3DXEffectPool}
  2747.   ID3DXEffectPool = interface(IUnknown)
  2748.     ['{53CA7768-C0D0-4664-8E79-D156E4F5B7E0}']
  2749.     // No public methods
  2750.   end;
  2751.  
  2752.  
  2753. //////////////////////////////////////////////////////////////////////////////
  2754. // ID3DXBaseEffect ///////////////////////////////////////////////////////////
  2755. //////////////////////////////////////////////////////////////////////////////
  2756.  
  2757.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXBaseEffect);'}
  2758.   {$EXTERNALSYM ID3DXBaseEffect}
  2759.   ID3DXBaseEffect = interface(IUnknown)
  2760.     ['{804EF574-CCC1-4bf6-B06A-B1404ABDEADE}']
  2761.     // Descs
  2762.     function GetDesc(out pDesc: TD3DXEffectDesc): HResult; stdcall;
  2763.     function GetParameterDesc(hParameter: TD3DXHandle; out pDesc: TD3DXParameterDesc): HResult; stdcall;
  2764.  
  2765.     function GetTechniqueDesc(hTechnique: TD3DXHandle; out pDesc: TD3DXTechniqueDesc): HResult; stdcall;
  2766.     function GetPassDesc(hPass: TD3DXHandle; out pDesc: TD3DXPassDesc): HResult; stdcall;
  2767.     function GetFunctionDesc(hShader: TD3DXHandle; out pDesc: TD3DXFunctionDesc): HResult; stdcall;
  2768.  
  2769.     // Handle operations
  2770.     function GetParameter(hParameter: TD3DXHandle; Index: LongWord): TD3DXHandle; stdcall;
  2771.     function GetParameterByName(hParameter: TD3DXHandle; pName: PAnsiChar): TD3DXHandle; stdcall;
  2772.     function GetParameterBySemantic(hParameter: TD3DXHandle; pSemantic: PAnsiChar): TD3DXHandle; stdcall;
  2773.     function GetParameterElement(hParameter: TD3DXHandle; Index: LongWord): TD3DXHandle; stdcall;
  2774.     function GetTechnique(Index: LongWord): TD3DXHandle; stdcall;
  2775.     function GetTechniqueByName(pName: PAnsiChar): TD3DXHandle; stdcall;
  2776.     function GetPass(hTechnique: TD3DXHandle; Index: LongWord): TD3DXHandle; stdcall;
  2777.     function GetPassByName(hTechnique: TD3DXHandle; pName: PAnsiChar): TD3DXHandle; stdcall;
  2778.     function GetFunction(Index: LongWord): TD3DXHandle; stdcall;
  2779.     function GetFunctionByName(pName: PAnsiChar): TD3DXHandle; stdcall;
  2780.     function GetAnnotation(hObject: TD3DXHandle; Index: LongWord): TD3DXHandle; stdcall;
  2781.     function GetAnnotationByName(hObject: TD3DXHandle; pName: PAnsiChar): TD3DXHandle; stdcall;
  2782.  
  2783.     // Get/Set Parameters
  2784.     function SetValue(hParameter: TD3DXHandle; pData: Pointer; Bytes: LongWord): HResult; stdcall;
  2785.     function GetValue(hParameter: TD3DXHandle; pData: Pointer; Bytes: LongWord): HResult; stdcall;
  2786.     function SetBool(hParameter: TD3DXHandle; b: BOOL): HResult; stdcall;
  2787.     function GetBool(hParameter: TD3DXHandle; out pb: BOOL): HResult; stdcall;
  2788.     function SetBoolArray(hParameter: TD3DXHandle; pb: PBOOL; Count: LongWord): HResult; stdcall;
  2789.     function GetBoolArray(hParameter: TD3DXHandle; pb: PBOOL; Count: LongWord): HResult; stdcall;
  2790.     function SetInt(hParameter: TD3DXHandle; n: Integer): HResult; stdcall;
  2791.     function GetInt(hParameter: TD3DXHandle; out pn: Integer): HResult; stdcall;
  2792.     function SetIntArray(hParameter: TD3DXHandle; pn: PInteger; Count: LongWord): HResult; stdcall;
  2793.     function GetIntArray(hParameter: TD3DXHandle; pn: PInteger; Count: LongWord): HResult; stdcall;
  2794.     function SetFloat(hParameter: TD3DXHandle; f: Single): HResult; stdcall;
  2795.     function GetFloat(hParameter: TD3DXHandle; out pf: Single): HResult; stdcall;
  2796.     function SetFloatArray(hParameter: TD3DXHandle; pf: PSingle; Count: LongWord): HResult; stdcall;
  2797.     function GetFloatArray(hParameter: TD3DXHandle; pf: PSingle; Count: LongWord): HResult; stdcall;
  2798.     function SetVector(hParameter: TD3DXHandle; const pVector: TD3DXVector4): HResult; stdcall;
  2799.     function GetVector(hParameter: TD3DXHandle; out pVector: TD3DXVector4): HResult; stdcall;
  2800.     function SetVectorArray(hParameter: TD3DXHandle; pVector: PD3DXVector4; Count: LongWord): HResult; stdcall;
  2801.     function GetVectorArray(hParameter: TD3DXHandle; pVector: PD3DXVector4; Count: LongWord): HResult; stdcall;
  2802.     function SetMatrix(hParameter: TD3DXHandle; const pMatrix: TD3DXMatrix): HResult; stdcall;
  2803.     function GetMatrix(hParameter: TD3DXHandle; out pMatrix: TD3DXMatrix): HResult; stdcall;
  2804.     function SetMatrixArray(hParameter: TD3DXHandle; pMatrix: PD3DXMatrix; Count: LongWord): HResult; stdcall;
  2805.     function GetMatrixArray(hParameter: TD3DXHandle; pMatrix: PD3DXMatrix; Count: LongWord): HResult; stdcall;
  2806.     function SetMatrixPointerArray(hParameter: TD3DXHandle; ppMatrix: PPD3DXMatrix; Count: LongWord): HResult; stdcall;
  2807.     function GetMatrixPointerArray(hParameter: TD3DXHandle; ppMatrix: PPD3DXMatrix; Count: LongWord): HResult; stdcall;
  2808.     function SetMatrixTranspose(hParameter: TD3DXHandle; const pMatrix: TD3DXMatrix): HResult; stdcall;
  2809.     function GetMatrixTranspose(hParameter: TD3DXHandle; out pMatrix: TD3DXMatrix): HResult; stdcall;
  2810.     function SetMatrixTransposeArray(hParameter: TD3DXHandle; pMatrix: PD3DXMatrix; Count: LongWord): HResult; stdcall;
  2811.     function GetMatrixTransposeArray(hParameter: TD3DXHandle; pMatrix: PD3DXMatrix; Count: LongWord): HResult; stdcall;
  2812.     function SetMatrixTransposePointerArray(hParameter: TD3DXHandle; ppMatrix: PPD3DXMatrix; Count: LongWord): HResult; stdcall;
  2813.     function GetMatrixTransposePointerArray(hParameter: TD3DXHandle; ppMatrix: PPD3DXMatrix; Count: LongWord): HResult; stdcall;
  2814.     function SetString(hParameter: TD3DXHandle; pString: PAnsiChar): HResult; stdcall;
  2815.     function GetString(hParameter: TD3DXHandle; out ppString: PAnsiChar): HResult; stdcall;
  2816.     function SetTexture(hParameter: TD3DXHandle; pTexture: IDirect3DBaseTexture9): HResult; stdcall;
  2817.     function GetTexture(hParameter: TD3DXHandle; out ppTexture: IDirect3DBaseTexture9): HResult; stdcall;
  2818.     function SetPixelShader(hParameter: TD3DXHandle; pPShader: IDirect3DPixelShader9): HResult; stdcall;
  2819.     function GetPixelShader(hParameter: TD3DXHandle; out ppPShader: IDirect3DPixelShader9): HResult; stdcall;
  2820.     function SetVertexShader(hParameter: TD3DXHandle; pVShader: IDirect3DVertexShader9): HResult; stdcall;
  2821.     function GetVertexShader(hParameter: TD3DXHandle; out ppVShader: IDirect3DVertexShader9): HResult; stdcall;
  2822.   end;
  2823.  
  2824.  
  2825. //////////////////////////////////////////////////////////////////////////////
  2826. // ID3DXEffect ///////////////////////////////////////////////////////////////
  2827. //////////////////////////////////////////////////////////////////////////////
  2828.  
  2829.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXEffect);'}
  2830.   {$EXTERNALSYM ID3DXEffect}
  2831.   ID3DXEffect = interface(ID3DXBaseEffect)
  2832.     ['{B589B04A-293D-4516-AF0B-3D7DBCF5AC54}']
  2833.     // Pool
  2834.     function GetPool(out ppPool: ID3DXEffectPool): HResult; stdcall;
  2835.  
  2836.     // Selecting and setting a technique
  2837.     function SetTechnique(hTechnique: TD3DXHandle): HResult; stdcall;
  2838.     function GetCurrentTechnique: TD3DXHandle; stdcall;
  2839.     function ValidateTechnique(hTechnique: TD3DXHandle): HResult; stdcall;
  2840.     function FindNextValidTechnique(hTechnique: TD3DXHandle; out pTechnique: TD3DXHandle): HResult; stdcall;
  2841.     function IsParameterUsed(hParameter: TD3DXHandle; hTechnique: TD3DXHandle): BOOL; stdcall;
  2842.  
  2843.     // Using current technique
  2844.     function _Begin(pPasses: PLongWord; Flags: DWORD): HResult; stdcall; 
  2845.     function Pass(Pass: LongWord): HResult; stdcall;
  2846.     function _End: HResult; stdcall;
  2847.  
  2848.     // Managing D3D Device
  2849.     function GetDevice(out ppDevice: IDirect3DDevice9): HResult; stdcall;
  2850.     function OnLostDevice: HResult; stdcall;
  2851.     function OnResetDevice: HResult; stdcall;
  2852.  
  2853.     // Cloning
  2854.     function CloneEffect(pDevice: IDirect3DDevice9; out ppEffect: ID3DXEffect): HResult; stdcall;
  2855.   end;
  2856.  
  2857.  
  2858. //////////////////////////////////////////////////////////////////////////////
  2859. // ID3DXEffectCompiler ///////////////////////////////////////////////////////
  2860. //////////////////////////////////////////////////////////////////////////////
  2861.  
  2862.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXEffectCompiler);'}
  2863.   {$EXTERNALSYM ID3DXEffectCompiler}
  2864.   ID3DXEffectCompiler = interface(ID3DXBaseEffect)
  2865.     ['{F8EE90D3-FCC6-4f14-8AE8-6374AE968E33}']
  2866.     // Parameter sharing, specialization, and information
  2867.     function SetLiteral(hParameter: TD3DXHandle; Literal: BOOL): HResult; stdcall;
  2868.     function GetLiteral(hParameter: TD3DXHandle; out pLiteral: BOOL): HResult; stdcall;
  2869.  
  2870.     // Compilation
  2871.     function CompileEffect(Flags: DWORD; ppEffect, ppErrorMsgs: PID3DXBuffer): HResult; stdcall;
  2872.  
  2873.     function CompileShader(hFunction: TD3DXHandle; pTarget: PAnsiChar; Flags: DWORD;
  2874.       ppShader, ppErrorMsgs: PID3DXBuffer; ppConstantTable: PID3DXConstantTable): HResult; stdcall;
  2875.   end;
  2876.  
  2877.  
  2878. //////////////////////////////////////////////////////////////////////////////
  2879. // APIs //////////////////////////////////////////////////////////////////////
  2880. //////////////////////////////////////////////////////////////////////////////
  2881.  
  2882.  
  2883. //----------------------------------------------------------------------------
  2884. // D3DXCreateEffectPool:
  2885. // ---------------------
  2886. // Creates an effect pool.  Pools are used for sharing parameters between
  2887. // multiple effects.  For all effects within a pool, shared parameters of the
  2888. // same name all share the same value.
  2889. //
  2890. // Parameters:
  2891. //  ppPool
  2892. //      Returns the created pool.
  2893. //----------------------------------------------------------------------------
  2894.  
  2895. function D3DXCreateEffectPool(
  2896.   out ppPool: ID3DXEffectPool): HResult; stdcall; external d3dx9effectDLL;
  2897. {$EXTERNALSYM D3DXCreateEffectPool}
  2898.  
  2899.  
  2900. //----------------------------------------------------------------------------
  2901. // D3DXCreateEffect:
  2902. // -----------------
  2903. // Creates an effect from an ascii or binary effect description.
  2904. //
  2905. // Parameters:
  2906. //  pDevice
  2907. //      Pointer of the device on which to create the effect
  2908. //  pSrcFile
  2909. //      Name of the file containing the effect description
  2910. //  hSrcModule
  2911. //      Module handle. if NULL, current module will be used.
  2912. //  pSrcResource
  2913. //      Resource name in module
  2914. //  pSrcData
  2915. //      Pointer to effect description
  2916. //  SrcDataSize
  2917. //      Size of the effect description in bytes
  2918. //  pDefines
  2919. //      Optional NULL-terminated array of preprocessor macro definitions.
  2920. //  pInclude
  2921. //      Optional interface pointer to use for handling #include directives.
  2922. //      If this parameter is NULL, #includes will be honored when compiling
  2923. //      from file, and will error when compiling from resource or memory.
  2924. //  pPool
  2925. //      Pointer to ID3DXEffectPool object to use for shared parameters.
  2926. //      If NULL, no parameters will be shared.
  2927. //  ppEffect
  2928. //      Returns a buffer containing created effect.
  2929. //  ppCompilationErrors
  2930. //      Returns a buffer containing any error messages which occurred during
  2931. //      compile.  Or NULL if you do not care about the error messages.
  2932. //
  2933. //----------------------------------------------------------------------------
  2934.  
  2935. function D3DXCreateEffectFromFileA(
  2936.   pDevice: IDirect3DDevice9;
  2937.   pSrcFile: PAnsiChar;
  2938.   pDefines: PD3DXMacro;
  2939.   pInclude: ID3DXInclude;
  2940.   Flags: DWORD;
  2941.   pPool: ID3DXEffectPool;
  2942.   out ppEffect: ID3DXEffect;
  2943.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx9effectDLL name 'D3DXCreateEffectFromFileA';
  2944. {$EXTERNALSYM D3DXCreateEffectFromFileA}
  2945.  
  2946. function D3DXCreateEffectFromFileW(
  2947.   pDevice: IDirect3DDevice9;
  2948.   pSrcFile: PWideChar;
  2949.   pDefines: PD3DXMacro;
  2950.   pInclude: ID3DXInclude;
  2951.   Flags: DWORD;
  2952.   pPool: ID3DXEffectPool;
  2953.   out ppEffect: ID3DXEffect;
  2954.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx9effectDLL name 'D3DXCreateEffectFromFileW';
  2955. {$EXTERNALSYM D3DXCreateEffectFromFileW}
  2956.  
  2957. function D3DXCreateEffectFromFile(
  2958.   pDevice: IDirect3DDevice9;
  2959.   pSrcFile: PChar;
  2960.   pDefines: PD3DXMacro;
  2961.   pInclude: ID3DXInclude;
  2962.   Flags: DWORD;
  2963.   pPool: ID3DXEffectPool;
  2964.   out ppEffect: ID3DXEffect;
  2965.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx9effectDLL name 'D3DXCreateEffectFromFileA';
  2966. {$EXTERNALSYM D3DXCreateEffectFromFile}
  2967.  
  2968.  
  2969. function D3DXCreateEffectFromResourceA(
  2970.   pDevice: IDirect3DDevice9;
  2971.   hSrcModule: HModule;
  2972.   pSrcResource: PAnsiChar;
  2973.   pDefines: PD3DXMacro;
  2974.   pInclude: ID3DXInclude;
  2975.   Flags: DWORD;
  2976.   pPool: ID3DXEffectPool;
  2977.   out ppEffect: ID3DXEffect;
  2978.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx9effectDLL name 'D3DXCreateEffectFromResourceA';
  2979. {$EXTERNALSYM D3DXCreateEffectFromResourceA}
  2980.  
  2981. function D3DXCreateEffectFromResourceW(
  2982.   pDevice: IDirect3DDevice9;
  2983.   hSrcModule: HModule;
  2984.   pSrcResource: PWideChar;
  2985.   pDefines: PD3DXMacro;
  2986.   pInclude: ID3DXInclude;
  2987.   Flags: DWORD;
  2988.   pPool: ID3DXEffectPool;
  2989.   out ppEffect: ID3DXEffect;
  2990.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx9effectDLL name 'D3DXCreateEffectFromResourceW';
  2991. {$EXTERNALSYM D3DXCreateEffectFromResourceW}
  2992.  
  2993. function D3DXCreateEffectFromResource(
  2994.   pDevice: IDirect3DDevice9;
  2995.   hSrcModule: HModule;
  2996.   pSrcResource: PChar;
  2997.   pDefines: PD3DXMacro;
  2998.   pInclude: ID3DXInclude;
  2999.   Flags: DWORD;
  3000.   pPool: ID3DXEffectPool;
  3001.   out ppEffect: ID3DXEffect;
  3002.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx9effectDLL name 'D3DXCreateEffectFromResourceA';
  3003. {$EXTERNALSYM D3DXCreateEffectFromResource}
  3004.  
  3005.  
  3006. function D3DXCreateEffect(
  3007.   pDevice: IDirect3DDevice9;
  3008.   pSrcData: Pointer;
  3009.   SrcDataLen: LongWord;
  3010.   pDefines: PD3DXMacro;
  3011.   pInclude: ID3DXInclude;
  3012.   Flags: DWORD;
  3013.   pPool: ID3DXEffectPool;
  3014.   out ppEffect: ID3DXEffect;
  3015.   ppCompilationErrors: PID3DXBuffer): HResult; stdcall; external d3dx9effectDLL;
  3016. {$EXTERNALSYM D3DXCreateEffect}
  3017.  
  3018.  
  3019.  
  3020. //----------------------------------------------------------------------------
  3021. // D3DXCreateEffectCompiler:
  3022. // -------------------------
  3023. // Creates an effect from an ascii or binary effect description.
  3024. //
  3025. // Parameters:
  3026. //  pSrcFile
  3027. //      Name of the file containing the effect description
  3028. //  hSrcModule
  3029. //      Module handle. if NULL, current module will be used.
  3030. //  pSrcResource
  3031. //      Resource name in module
  3032. //  pSrcData
  3033. //      Pointer to effect description
  3034. //  SrcDataSize
  3035. //      Size of the effect description in bytes
  3036. //  pDefines
  3037. //      Optional NULL-terminated array of preprocessor macro definitions.
  3038. //  pInclude
  3039. //      Optional interface pointer to use for handling #include directives.
  3040. //      If this parameter is NULL, #includes will be honored when compiling
  3041. //      from file, and will error when compiling from resource or memory.
  3042. //  pPool
  3043. //      Pointer to ID3DXEffectPool object to use for shared parameters.
  3044. //      If NULL, no parameters will be shared.
  3045. //  ppCompiler
  3046. //      Returns a buffer containing created effect compiler.
  3047. //  ppParseErrors
  3048. //      Returns a buffer containing any error messages which occurred during
  3049. //      parse.  Or NULL if you do not care about the error messages.
  3050. //
  3051. //----------------------------------------------------------------------------
  3052.  
  3053. function D3DXCreateEffectCompilerFromFileA(
  3054.   pSrcFile: PAnsiChar;
  3055.   pDefines: PD3DXMacro;
  3056.   pInclude: ID3DXInclude;
  3057.   Flags: DWORD;
  3058.   out ppCompiler: ID3DXEffectCompiler;
  3059.   ppParseErrors: PID3DXBuffer): HResult; stdcall; external d3dx9effectDLL name 'D3DXCreateEffectCompilerFromFileA';
  3060. {$EXTERNALSYM D3DXCreateEffectCompilerFromFileA}
  3061.  
  3062. function D3DXCreateEffectCompilerFromFileW(
  3063.   pSrcFile: PWideChar;
  3064.   pDefines: PD3DXMacro;
  3065.   pInclude: ID3DXInclude;
  3066.   Flags: DWORD;
  3067.   out ppCompiler: ID3DXEffectCompiler;
  3068.   ppParseErrors: PID3DXBuffer): HResult; stdcall; external d3dx9effectDLL name 'D3DXCreateEffectCompilerFromFileW';
  3069. {$EXTERNALSYM D3DXCreateEffectCompilerFromFileW}
  3070.  
  3071. function D3DXCreateEffectCompilerFromFile(
  3072.   pSrcFile: PChar;
  3073.   pDefines: PD3DXMacro;
  3074.   pInclude: ID3DXInclude;
  3075.   Flags: DWORD;
  3076.   out ppCompiler: ID3DXEffectCompiler;
  3077.   ppParseErrors: PID3DXBuffer): HResult; stdcall; external d3dx9effectDLL name 'D3DXCreateEffectCompilerFromFileA';
  3078. {$EXTERNALSYM D3DXCreateEffectCompilerFromFile}
  3079.  
  3080.  
  3081. function D3DXCreateEffectCompilerFromResourceA(
  3082.   hSrcModule: HModule;
  3083.   pSrcResource: PAnsiChar;
  3084.   pDefines: PD3DXMacro;
  3085.   pInclude: ID3DXInclude;
  3086.   Flags: DWORD;
  3087.   out ppCompiler: ID3DXEffectCompiler;
  3088.   ppParseErrors: PID3DXBuffer): HResult; stdcall; external d3dx9effectDLL name 'D3DXCreateEffectCompilerFromResourceA';
  3089. {$EXTERNALSYM D3DXCreateEffectCompilerFromResourceA}
  3090.  
  3091. function D3DXCreateEffectCompilerFromResourceW(
  3092.   hSrcModule: HModule;
  3093.   pSrcResource: PWideChar;
  3094.   pDefines: PD3DXMacro;
  3095.   pInclude: ID3DXInclude;
  3096.   Flags: DWORD;
  3097.   out ppCompiler: ID3DXEffectCompiler;
  3098.   ppParseErrors: PID3DXBuffer): HResult; stdcall; external d3dx9effectDLL name 'D3DXCreateEffectCompilerFromResourceW';
  3099. {$EXTERNALSYM D3DXCreateEffectCompilerFromResourceW}
  3100.  
  3101. function D3DXCreateEffectCompilerFromResource(
  3102.   hSrcModule: HModule;
  3103.   pSrcResource: PChar;
  3104.   pDefines: PD3DXMacro;
  3105.   pInclude: ID3DXInclude;
  3106.   Flags: DWORD;
  3107.   out ppCompiler: ID3DXEffectCompiler;
  3108.   ppParseErrors: PID3DXBuffer): HResult; stdcall; external d3dx9effectDLL name 'D3DXCreateEffectCompilerFromResourceA';
  3109. {$EXTERNALSYM D3DXCreateEffectCompilerFromResource}
  3110.  
  3111.  
  3112. function D3DXCreateEffectCompiler(
  3113.   pSrcData: Pointer;
  3114.   SrcDataLen: LongWord;
  3115.   pDefines: PD3DXMacro;
  3116.   pInclude: ID3DXInclude;
  3117.   Flags: DWORD;
  3118.   out ppCompiler: ID3DXEffectCompiler;
  3119.   ppParseErrors: PID3DXBuffer): HResult; stdcall; external d3dx9effectDLL;
  3120. {$EXTERNALSYM D3DXCreateEffectCompiler}
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126. //////////////////////////////////////////////////////////////////////////////
  3127. //
  3128. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  3129. //
  3130. //  File:       d3dx9mesh.h
  3131. //  Content:    D3DX mesh types and functions
  3132. //
  3133. //////////////////////////////////////////////////////////////////////////////
  3134.  
  3135. type
  3136.   //patch mesh can be quads or tris
  3137.   _D3DXPATCHMESHTYPE = (
  3138.   {$IFNDEF COMPILER6_UP}
  3139.     D3DXPATCHMESH_invalid_0,
  3140.     D3DXPATCHMESH_RECT   {= $001},
  3141.     D3DXPATCHMESH_TRI    {= $002},
  3142.     D3DXPATCHMESH_NPATCH {= $003}
  3143.   {$ELSE}
  3144.     D3DXPATCHMESH_RECT   = $001,
  3145.     D3DXPATCHMESH_TRI    = $002,
  3146.     D3DXPATCHMESH_NPATCH = $003
  3147.   {$ENDIF}
  3148.   );
  3149.   {$EXTERNALSYM _D3DXPATCHMESHTYPE}
  3150.   D3DXPATCHMESHTYPE = _D3DXPATCHMESHTYPE;
  3151.   {$EXTERNALSYM D3DXPATCHMESHTYPE}
  3152.   TD3DXPatchMeshType = _D3DXPATCHMESHTYPE;
  3153.  
  3154. type
  3155.   _D3DXMESH = {$IFDEF TYPE_IDENTITY}type {$ENDIF}DWord;
  3156.   {$EXTERNALSYM _D3DXMESH}
  3157.   TD3DXMesh = _D3DXMESH;
  3158.  
  3159. // Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags
  3160. const
  3161.   D3DXMESH_32BIT                  = $001; // If set, then use 32 bit indices, if not set use 16 bit indices.
  3162.   {$EXTERNALSYM D3DXMESH_32BIT}
  3163.   D3DXMESH_DONOTCLIP              = $002; // Use D3DUSAGE_DONOTCLIP for VB & IB.
  3164.   {$EXTERNALSYM D3DXMESH_DONOTCLIP}
  3165.   D3DXMESH_POINTS                 = $004; // Use D3DUSAGE_POINTS for VB & IB.
  3166.   {$EXTERNALSYM D3DXMESH_POINTS}
  3167.   D3DXMESH_RTPATCHES              = $008; // Use D3DUSAGE_RTPATCHES for VB & IB.
  3168.   {$EXTERNALSYM D3DXMESH_RTPATCHES}
  3169.   D3DXMESH_NPATCHES      = $4000;// Use D3DUSAGE_NPATCHES for VB & IB.
  3170.   {$EXTERNALSYM D3DXMESH_NPATCHES}
  3171.   D3DXMESH_VB_SYSTEMMEM      = $010; // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER
  3172.   {$EXTERNALSYM D3DXMESH_VB_SYSTEMMEM}
  3173.   D3DXMESH_VB_MANAGED             = $020; // Use D3DPOOL_MANAGED for VB.
  3174.   {$EXTERNALSYM D3DXMESH_VB_MANAGED}
  3175.   D3DXMESH_VB_WRITEONLY           = $040; // Use D3DUSAGE_WRITEONLY for VB.
  3176.   {$EXTERNALSYM D3DXMESH_VB_WRITEONLY}
  3177.   D3DXMESH_VB_DYNAMIC             = $080; // Use D3DUSAGE_DYNAMIC for VB.
  3178.   {$EXTERNALSYM D3DXMESH_VB_DYNAMIC}
  3179.   D3DXMESH_VB_SOFTWAREPROCESSING = $8000; // Use D3DUSAGE_SOFTWAREPROCESSING for VB.
  3180.   {$EXTERNALSYM D3DXMESH_VB_SOFTWAREPROCESSING}
  3181.   D3DXMESH_IB_SYSTEMMEM      = $100; // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER
  3182.   {$EXTERNALSYM D3DXMESH_IB_SYSTEMMEM}
  3183.   D3DXMESH_IB_MANAGED             = $200; // Use D3DPOOL_MANAGED for IB.
  3184.   {$EXTERNALSYM D3DXMESH_IB_MANAGED}
  3185.   D3DXMESH_IB_WRITEONLY           = $400; // Use D3DUSAGE_WRITEONLY for IB.
  3186.   {$EXTERNALSYM D3DXMESH_IB_WRITEONLY}
  3187.   D3DXMESH_IB_DYNAMIC             = $800; // Use D3DUSAGE_DYNAMIC for IB.
  3188.   {$EXTERNALSYM D3DXMESH_IB_DYNAMIC}
  3189.   D3DXMESH_IB_SOFTWAREPROCESSING= $10000; // Use D3DUSAGE_SOFTWAREPROCESSING for IB.
  3190.   {$EXTERNALSYM D3DXMESH_IB_SOFTWAREPROCESSING}
  3191.  
  3192.   D3DXMESH_VB_SHARE               = $1000; // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer
  3193.   {$EXTERNALSYM D3DXMESH_VB_SHARE}
  3194.  
  3195.   D3DXMESH_USEHWONLY              = $2000; // Valid for ID3DXSkinMesh::ConvertToBlendedMesh
  3196.   {$EXTERNALSYM D3DXMESH_USEHWONLY}
  3197.  
  3198.   // Helper options
  3199.   D3DXMESH_SYSTEMMEM      = $110; // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM
  3200.   {$EXTERNALSYM D3DXMESH_SYSTEMMEM}
  3201.   D3DXMESH_MANAGED                = $220; // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED
  3202.   {$EXTERNALSYM D3DXMESH_MANAGED}
  3203.   D3DXMESH_WRITEONLY              = $440; // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY
  3204.   {$EXTERNALSYM D3DXMESH_WRITEONLY}
  3205.   D3DXMESH_DYNAMIC                = $880; // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC
  3206.   {$EXTERNALSYM D3DXMESH_DYNAMIC}
  3207.   D3DXMESH_SOFTWAREPROCESSING   = $18000; // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING
  3208.   {$EXTERNALSYM D3DXMESH_SOFTWAREPROCESSING}
  3209.  
  3210. type
  3211.   //patch mesh options
  3212.   _D3DXPATCHMESH = (
  3213.     D3DXPATCHMESH_DEFAULT {= 000,}
  3214.   );
  3215.   {$EXTERNALSYM _D3DXPATCHMESH}
  3216.   D3DXPATCHMESH = _D3DXPATCHMESH;
  3217.   {$EXTERNALSYM D3DXPATCHMESH}
  3218.   TD3DXPatchMesh = _D3DXPATCHMESH;
  3219.  
  3220.   // option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh
  3221.   _D3DXMESHSIMP = (
  3222.   {$IFNDEF COMPILER6_UP}
  3223.     D3DXMESHSIMP_invalid_0{= 0x0},
  3224.     D3DXMESHSIMP_VERTEX   {= 0x1},
  3225.     D3DXMESHSIMP_FACE     {= 0x2}
  3226.   {$ELSE}
  3227.     D3DXMESHSIMP_VERTEX   = $1,
  3228.     D3DXMESHSIMP_FACE     = $2
  3229.   {$ENDIF}
  3230.   );
  3231.   {$EXTERNALSYM _D3DXMESHSIMP}
  3232.   TD3DMeshSimp = _D3DXMESHSIMP;
  3233.  
  3234.   _MAX_FVF_DECL_SIZE = DWord;
  3235.   {$EXTERNALSYM _MAX_FVF_DECL_SIZE}
  3236. const
  3237.   MAX_FVF_DECL_SIZE = MAXD3DDECLLENGTH + 1; // +1 for END
  3238.   {$EXTERNALSYM MAX_FVF_DECL_SIZE}
  3239.  
  3240. type
  3241.   TFVFDeclaration = array [0..MAX_FVF_DECL_SIZE-1] of TD3DVertexElement9;
  3242.  
  3243.   PD3DXAttributeRange = ^TD3DXAttributeRange;
  3244.   _D3DXATTRIBUTERANGE = packed record
  3245.     AttribId:    DWord;
  3246.     FaceStart:   DWord;
  3247.     FaceCount:   DWord;
  3248.     VertexStart: DWord;
  3249.     VertexCount: DWord;
  3250.   end;
  3251.   {$EXTERNALSYM _D3DXATTRIBUTERANGE}
  3252.   D3DXATTRIBUTERANGE = _D3DXATTRIBUTERANGE;
  3253.   {$EXTERNALSYM D3DXATTRIBUTERANGE}
  3254.   TD3DXAttributeRange = _D3DXATTRIBUTERANGE;
  3255.  
  3256.   PD3DXMaterial = ^TD3DXMaterial;
  3257.   _D3DXMATERIAL = packed record
  3258.     MatD3D: TD3Dmaterial9;
  3259.     pTextureFilename: PAnsiChar;
  3260.   end;
  3261.   {$EXTERNALSYM _D3DXMATERIAL}
  3262.   D3DXMATERIAL = _D3DXMATERIAL;
  3263.   {$EXTERNALSYM D3DXMATERIAL}
  3264.   TD3DXMaterial = _D3DXMATERIAL;
  3265.  
  3266.   _D3DXEFFECTDEFAULTTYPE = (
  3267.   {$IFNDEF COMPILER6_UP}
  3268.     D3DXEDT_invalid_0,
  3269.     D3DXEDT_STRING {= $1},      // pValue points to a null terminated ASCII string
  3270.     D3DXEDT_FLOATS {= $2},      // pValue points to an array of floats - number of floats is NumBytes / sizeof(float)
  3271.     D3DXEDT_DWORD  {= $3}       // pValue points to a DWORD
  3272.   {$ELSE}
  3273.     D3DXEDT_STRING = $1,        // pValue points to a null terminated ASCII string
  3274.     D3DXEDT_FLOATS = $2,        // pValue points to an array of floats - number of floats is NumBytes / sizeof(float)
  3275.     D3DXEDT_DWORD  = $3         // pValue points to a DWORD
  3276.   {$ENDIF}
  3277.   );
  3278.   {$EXTERNALSYM _D3DXEFFECTDEFAULTTYPE}
  3279.   D3DXEFFECTDEFAULTTYPE = _D3DXEFFECTDEFAULTTYPE;
  3280.   {$EXTERNALSYM D3DXEFFECTDEFAULTTYPE}
  3281.   TD3DXEffectDefaultType = _D3DXEFFECTDEFAULTTYPE;
  3282.  
  3283.   PD3DXEffectDefault = ^TD3DXEffectDefault;
  3284.   _D3DXEFFECTDEFAULT = packed record
  3285.     pParamName: PAnsiChar;
  3286.     _Type: TD3DXEffectDefaultType;        // type of the data pointed to by pValue
  3287.     NumBytes: DWORD;                      // size in bytes of the data pointed to by pValue
  3288.     pValue: Pointer;                      // data for the default of the effect
  3289.   end;
  3290.   {$EXTERNALSYM _D3DXEFFECTDEFAULT}
  3291.   D3DXEFFECTDEFAULT = _D3DXEFFECTDEFAULT;
  3292.   {$EXTERNALSYM D3DXEFFECTDEFAULT}
  3293.   TD3DXEffectDefault = _D3DXEFFECTDEFAULT;
  3294.  
  3295.   PD3DXEffectInstance = ^TD3DXEffectInstance;
  3296.   _D3DXEFFECTINSTANCE = packed record
  3297.     pEffectFilename: PAnsiChar;
  3298.     NumDefaults: DWORD;
  3299.     pDefaults: PD3DXEffectDefault;
  3300.   end;
  3301.   {$EXTERNALSYM _D3DXEFFECTINSTANCE}
  3302.   D3DXEFFECTINSTANCE = _D3DXEFFECTINSTANCE;
  3303.   {$EXTERNALSYM D3DXEFFECTINSTANCE}
  3304.   TD3DXEffectInstance = _D3DXEFFECTINSTANCE;
  3305.  
  3306.   PD3DXAttributeWeights = ^TD3DXAttributeWeights;
  3307.   _D3DXATTRIBUTEWEIGHTS = packed record
  3308.     Position: Single;
  3309.     Boundary: Single;
  3310.     Normal:   Single;
  3311.     Diffuse:  Single;
  3312.     Specular: Single;
  3313.     Texcoord: array[0..7] of Single;
  3314.     Tangent: Single;
  3315.     Binormal: Single;
  3316.   end;
  3317.   {$EXTERNALSYM _D3DXATTRIBUTEWEIGHTS}
  3318.   D3DXATTRIBUTEWEIGHTS = _D3DXATTRIBUTEWEIGHTS;
  3319.   {$EXTERNALSYM D3DXATTRIBUTEWEIGHTS}
  3320.   TD3DXAttributeWeights = _D3DXATTRIBUTEWEIGHTS;
  3321.  
  3322.   _D3DXWELDEPSILONSFLAGS = {$IFDEF TYPE_IDENTITY}type {$ENDIF}DWord;
  3323.   {$EXTERNALSYM _D3DXWELDEPSILONSFLAGS}
  3324.   TD3DXWeldEpsilonsFlags = _D3DXWELDEPSILONSFLAGS;
  3325.  
  3326. const
  3327.   D3DXWELDEPSILONS_WELDALL = $1;              // weld all vertices marked by adjacency as being overlapping
  3328.   {$EXTERNALSYM D3DXWELDEPSILONS_WELDALL}
  3329.  
  3330.   D3DXWELDEPSILONS_WELDPARTIALMATCHES = $2;   // if a given vertex component is within epsilon, modify partial matched
  3331.                                                  // vertices so that both components identical AND if all components "equal"
  3332.                                                  // remove one of the vertices
  3333.   {$EXTERNALSYM D3DXWELDEPSILONS_WELDPARTIALMATCHES}
  3334.   D3DXWELDEPSILONS_DONOTREMOVEVERTICES = $4;  // instructs weld to only allow modifications to vertices and not removal
  3335.                                                  // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set
  3336.                                                  // useful to modify vertices to be equal, but not allow vertices to be removed
  3337.   {$EXTERNALSYM D3DXWELDEPSILONS_DONOTREMOVEVERTICES}
  3338.   D3DXWELDEPSILONS_DONOTSPLIT          = $8;  // instructs weld to specify the D3DXMESHOPT_DONOTSPLIT flag when doing an Optimize(ATTR_SORT)
  3339.                                                  // if this flag is not set, all vertices that are in separate attribute groups
  3340.                                                  // will remain split and not welded.  Setting this flag can slow down software vertex processing
  3341.   {$EXTERNALSYM D3DXWELDEPSILONS_DONOTSPLIT}
  3342.  
  3343. type
  3344.   PD3DXWeldEpsilons = ^TD3DXWeldEpsilons;
  3345.   _D3DXWELDEPSILONS = packed record
  3346.     Position: Single; // NOTE: This does NOT replace the epsilon in GenerateAdjacency
  3347.                       // in general, it should be the same value or greater than the one passed to GeneratedAdjacency
  3348.     BlendWeights: Single;
  3349.     Normal: Single;
  3350.     PSize: Single;
  3351.     Specular: Single;
  3352.     Diffuse: Single;
  3353.     Texcoord: array[0..7] of Single;
  3354.     Tangent: Single;
  3355.     Binormal: Single;
  3356.     TessFactor: Single;
  3357.   end;
  3358.   {$EXTERNALSYM _D3DXWELDEPSILONS}
  3359.   D3DXWELDEPSILONS = _D3DXWELDEPSILONS;
  3360.   {$EXTERNALSYM D3DXWELDEPSILONS}
  3361.   TD3DXWeldEpsilons = _D3DXWELDEPSILONS;
  3362.  
  3363.   ID3DXMesh = interface;
  3364.  
  3365.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXBaseMesh);'}
  3366.   {$EXTERNALSYM ID3DXBaseMesh}
  3367.   ID3DXBaseMesh = interface(IUnknown)
  3368.     ['{2A835771-BF4D-43f4-8E14-82A809F17D8A}']
  3369.     // ID3DXBaseMesh
  3370.     function DrawSubset(AttribId: DWord): HResult; stdcall;
  3371.     function GetNumFaces: DWord; stdcall;
  3372.     function GetNumVertices: DWord; stdcall;
  3373.     function GetFVF: DWord; stdcall;
  3374.     function GetDeclaration(out Declaration: TFVFDeclaration): HResult; stdcall;
  3375.     function GetNumBytesPerVertex: DWORD;
  3376.     function GetOptions: DWord; stdcall;
  3377.     function GetDevice(out ppDevice: IDirect3DDevice9): HResult; stdcall;
  3378.     function CloneMeshFVF(Options, FVF: DWord; pD3DDevice: IDirect3DDevice9;
  3379.       out ppCloneMesh: ID3DXMesh): HResult; stdcall;
  3380.     function CloneMesh(Options: DWORD; pDeclaration: PD3DVertexElement9;
  3381.       pD3DDevice: IDirect3DDevice9; out ppCloneMesh: ID3DXMesh): HResult; stdcall;
  3382.     function GetVertexBuffer(out ppVB: IDirect3DVertexBuffer9): HResult; stdcall;
  3383.     function GetIndexBuffer(out ppIB: IDirect3DIndexBuffer9): HResult; stdcall;
  3384.     function LockVertexBuffer(Flags: DWord; out ppData: Pointer): HResult; stdcall;
  3385.     function UnlockVertexBuffer: HResult; stdcall;
  3386.     function LockIndexBuffer(Flags: DWord; out ppData: Pointer): HResult; stdcall;
  3387.     function UnlockIndexBuffer: HResult; stdcall;
  3388.     function GetAttributeTable(pAttribTable: PD3DXAttributeRange;
  3389.       pAttribTableSize: PDWord): HResult; stdcall;
  3390.  
  3391.     function ConvertPointRepsToAdjacency(pPRep: PDWord; pAdjacency: PDWord): HResult; stdcall;
  3392.     function ConvertAdjacencyToPointReps(pAdjacency: PDWord; pPRep: PDWord): HResult; stdcall;
  3393.     function GenerateAdjacency(Epsilon: Single; pAdjacency: PDWord): HResult; stdcall;
  3394.  
  3395.     function UpdateSemantics(const Declaration: TFVFDeclaration): HResult; stdcall;
  3396.   end;
  3397.  
  3398.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXMesh);'}
  3399.   {$EXTERNALSYM ID3DXMesh}
  3400.   ID3DXMesh = interface(ID3DXBaseMesh)
  3401.     ['{CCAE5C3B-4DD1-4d0f-997E-4684CA64557F}']
  3402.     // ID3DXMesh
  3403.     function LockAttributeBuffer(Flags: DWord; out ppData: PByte): HResult; stdcall;
  3404.     function UnlockAttributeBuffer: HResult; stdcall;
  3405.     function Optimize(Flags: DWord; pAdjacencyIn, pAdjacencyOut: PDWord;
  3406.       pFaceRemap: PDWord; ppVertexRemap: PID3DXBuffer;
  3407.       out ppOptMesh: ID3DXMesh): HResult; stdcall;
  3408.     function OptimizeInplace(Flags: DWord; pAdjacencyIn, pAdjacencyOut: PDWord;
  3409.       pFaceRemap: PDWord; ppVertexRemap: PID3DXBuffer): HResult; stdcall;
  3410.     function SetAttributeTable(pAttribTable: PD3DXAttributeRange; cAttribTableSize: DWORD): HResult; stdcall;
  3411.   end;
  3412.  
  3413.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXPMesh);'}
  3414.   {$EXTERNALSYM ID3DXPMesh}
  3415.   ID3DXPMesh = interface(ID3DXBaseMesh)
  3416.     ['{19FBE386-C282-4659-97BD-CB869B084A6C}']
  3417.     // ID3DXPMesh
  3418.     function ClonePMeshFVF(Options, FVF: DWord; ppDevice: IDirect3DDevice9;
  3419.       out ppCloneMesh: ID3DXPMesh): HResult; stdcall;
  3420.     function ClonePMesh(Options: DWORD; pDeclaration: PD3DVertexElement9;
  3421.       pD3D: IDirect3DDevice9; out ppCloneMesh: ID3DXPMesh): HResult; stdcall;
  3422.     function SetNumFaces(Faces: DWord): HResult; stdcall;
  3423.     function SetNumVertices(Vertices: DWord): HResult; stdcall;
  3424.     function GetMaxFaces: DWord; stdcall;
  3425.     function GetMinFaces: DWord; stdcall;
  3426.     function GetMaxVertices: DWord; stdcall;
  3427.     function GetMinVertices: DWord; stdcall;
  3428.     function Save(pStream: IStream; pMaterials: PD3DXMaterial;
  3429.       pEffectInstances: PD3DXEffectInstance; NumMaterials: DWORD): HResult; stdcall;
  3430.  
  3431.     function Optimize(Flags: DWord; pAdjacencyOut: PDWord;
  3432.       pFaceRemap: PDWord; ppVertexRemap: PID3DXBuffer;
  3433.       out ppOptMesh: ID3DXMesh): HResult; stdcall;
  3434.  
  3435.     function OptimizeBaseLOD(Flags: DWord; pFaceRemap: PDWord): HResult; stdcall;
  3436.     function TrimByFaces(NewFacesMin, NewFacesMax: DWord; rgiFaceRemap, rgiVertRemap: PDWord): HResult; stdcall;
  3437.     function TrimByVertices(NewVerticesMin, NewVerticesMax: DWord; rgiFaceRemap, rgiVertRemap: PDWord): HResult; stdcall;
  3438.  
  3439.     function GetAdjacency(pAdjacency: PDWord): HResult; stdcall;
  3440.  
  3441.     //  Used to generate the immediate "ancestor" for each vertex when it is removed by a vsplit.  Allows generation of geomorphs
  3442.     //     Vertex buffer must be equal to or greater than the maximum number of vertices in the pmesh
  3443.     function GenerateVertexHistory(pVertexHistory: PDWORD): HResult; stdcall;
  3444.   end;
  3445.  
  3446.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXSPMesh);'}
  3447.   {$EXTERNALSYM ID3DXSPMesh}
  3448.   ID3DXSPMesh = interface(IUnknown)
  3449.     ['{4E3CA05C-D4FF-4d11-8A02-16459E08F6F4}']
  3450.     // ID3DXSPMesh
  3451.     function GetNumFaces: DWord; stdcall;
  3452.     function GetNumVertices: DWord; stdcall;
  3453.     function GetFVF: DWord; stdcall;
  3454.     function GetDeclaration(out Declaration: TFVFDeclaration): HResult; stdcall;
  3455.     function GetOptions: DWord; stdcall;
  3456.     function GetDevice(out ppDevice: IDirect3DDevice9): HResult; stdcall;
  3457.     function CloneMeshFVF(Options, FVF: DWord; ppDevice: IDirect3DDevice9;
  3458.       pAdjacencyOut, pVertexRemapOut: PDWord;
  3459.       out ppCloneMesh: ID3DXMesh): HResult; stdcall;
  3460.     function CloneMesh(Options: DWORD; pDeclaration: PD3DVertexElement9;
  3461.       pD3DDevice: IDirect3DDevice9; pAdjacencyOut, pVertexRemapOut: PDWORD;
  3462.       out ppCloneMesh: ID3DXMesh): HResult; stdcall;
  3463.     function ClonePMeshFVF(Options, FVF: DWORD; pD3D: IDirect3DDevice9;
  3464.       pVertexRemapOut: PDWORD; pErrorsByFace: PSingle; out ppCloneMesh: ID3DXPMesh): HResult; stdcall;
  3465.     function ClonePMesh(Options: DWORD; pDeclaration: PD3DVertexElement9;
  3466.       pD3D: IDirect3DDevice9; pVertexRemapOut: PDWORD; pErrorsbyFace: PSingle;
  3467.       out ppCloneMesh: ID3DXPMesh): HResult; stdcall;
  3468.     function ReduceFaces(Faces: DWord): HResult; stdcall;
  3469.     function ReduceVertices(Vertices: DWord): HResult; stdcall;
  3470.     function GetMaxFaces: DWord; stdcall;
  3471.     function GetMaxVertices: DWord; stdcall;
  3472.     function GetVertexAttributeWeights(pVertexAttributeWeights: PD3DXAttributeWeights): HResult; stdcall;
  3473.     function GetVertexWeights(pVertexWeights: PSingle): HResult; stdcall;
  3474.   end;
  3475.  
  3476. const
  3477.   UNUSED16      = $ffff;
  3478.   {$EXTERNALSYM UNUSED16}
  3479.   UNUSED32      = $ffffffff;
  3480.   {$EXTERNALSYM UNUSED32}
  3481.  
  3482. // ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags
  3483. type
  3484.   _D3DXMESHOPT = {$IFDEF TYPE_IDENTITY}type {$ENDIF}DWord;
  3485.   {$EXTERNALSYM _D3DXMESHOPT}
  3486.   TD3DXMeshOpt = _D3DXMESHOPT;
  3487.  
  3488. const
  3489.   D3DXMESHOPT_COMPACT       = $01000000;
  3490.   {$EXTERNALSYM D3DXMESHOPT_COMPACT}
  3491.   D3DXMESHOPT_ATTRSORT      = $02000000;
  3492.   {$EXTERNALSYM D3DXMESHOPT_ATTRSORT}
  3493.   D3DXMESHOPT_VERTEXCACHE   = $04000000;
  3494.   {$EXTERNALSYM D3DXMESHOPT_VERTEXCACHE}
  3495.   D3DXMESHOPT_STRIPREORDER  = $08000000;
  3496.   {$EXTERNALSYM D3DXMESHOPT_STRIPREORDER}
  3497.   D3DXMESHOPT_IGNOREVERTS   = $10000000;  // optimize faces only; don't touch vertices
  3498.   {$EXTERNALSYM D3DXMESHOPT_IGNOREVERTS}
  3499.   D3DXMESHOPT_DONOTSPLIT    = $20000000;  // do not split vertices shared between attribute groups when attribute sorting
  3500.   {$EXTERNALSYM D3DXMESHOPT_DONOTSPLIT}
  3501.   D3DXMESHOPT_DEVICEINDEPENDENT = $00400000;  // Only affects VCache.  uses a static known good cache size for all cards
  3502.   {$EXTERNALSYM D3DXMESHOPT_DEVICEINDEPENDENT}
  3503.  
  3504.   // D3DXMESHOPT_SHAREVB has been removed, please use D3DXMESH_VB_SHARE instead
  3505.  
  3506. // Subset of the mesh that has the same attribute and bone combination.
  3507. // This subset can be rendered in a single draw call
  3508. type
  3509.   PDWordArray = ^TDWordArray;
  3510.   {$NODEFINE PDWordArray}
  3511.   TDWordArray = array[0..MaxInt div SizeOf(DWORD) - 1] of DWord;
  3512.   {$NODEFINE TDWordArray}
  3513.  
  3514.   PD3DXBoneCombination = ^TD3DXBoneCombination;
  3515.   _D3DXBONECOMBINATION = packed record
  3516.     AttribId: DWord;
  3517.     FaceStart: DWord;
  3518.     FaceCount: DWord;
  3519.     VertexStart: DWord;
  3520.     VertexCount: DWord;
  3521.     BoneId: PDWordArray; // [ DWORD* ]  in original d3dx8mesh.h
  3522.   end;
  3523.   {$EXTERNALSYM _D3DXBONECOMBINATION}
  3524.   D3DXBONECOMBINATION = _D3DXBONECOMBINATION;
  3525.   {$EXTERNALSYM D3DXBONECOMBINATION}
  3526.   TD3DXBoneCombination = _D3DXBONECOMBINATION;
  3527.  
  3528. // The following types of patch combinations are supported:
  3529. // Patch type   Basis       Degree
  3530. // Rect         Bezier      2,3,5
  3531. // Rect         B-Spline    2,3,5
  3532. // Rect         Catmull-Rom 3
  3533. // Tri          Bezier      2,3,5
  3534. // N-Patch      N/A         3
  3535.  
  3536.   PD3DXPatchInfo = ^TD3DXPatchInfo;
  3537.   _D3DXPATCHINFO = packed record
  3538.     PatchType: TD3DXPatchMeshType;
  3539.     Degree: TD3DDegreeType;
  3540.     Basis: TD3DBasisType;
  3541.   end;
  3542.   {$EXTERNALSYM _D3DXPATCHINFO}
  3543.   D3DXPATCHINFO = _D3DXPATCHINFO;
  3544.   {$EXTERNALSYM D3DXPATCHINFO}
  3545.   TD3DXPatchInfo = _D3DXPATCHINFO;
  3546.  
  3547.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXPatchMesh);'}
  3548.   {$EXTERNALSYM ID3DXPatchMesh}
  3549.   ID3DXPatchMesh = interface(IUnknown)
  3550.     ['{0AD3E8BC-290D-4dc7-91AB-73A82755B13E}']
  3551.     // ID3DXPatchMesh
  3552.  
  3553.     // Return creation parameters
  3554.     function GetNumPatches: DWORD; stdcall;
  3555.     function GetNumVertices: DWORD; stdcall;
  3556.     function GetDeclaration(pDeclaration: PD3DVertexElement9): HResult; stdcall;
  3557.     function GetControlVerticesPerPatch: DWORD; stdcall;
  3558.     function GetOptions: DWORD; stdcall;
  3559.     function GetDevice(out ppDevice: IDirect3DDevice9): HResult; stdcall;
  3560.     function GetPatchInfo(out PatchInfo: TD3DXPatchInfo): HResult; stdcall;
  3561.  
  3562.     // Control mesh access    
  3563.     function GetVertexBuffer(out ppVB: IDirect3DVertexBuffer9): HResult; stdcall;
  3564.     function GetIndexBuffer(out ppIB: IDirect3DIndexBuffer9): HResult; stdcall;
  3565.     function LockVertexBuffer(flags: DWORD; out ppData: Pointer): HResult; stdcall;
  3566.     function UnlockVertexBuffer: HResult; stdcall;
  3567.     function LockIndexBuffer(flags: DWORD; out ppData: Pointer): HResult; stdcall;
  3568.     function UnlockIndexBuffer: HResult; stdcall;
  3569.     function LockAttributeBuffer(flags: DWORD; out ppData: PDWORD): HResult; stdcall;
  3570.     function UnlockAttributeBuffer: HResult; stdcall;
  3571.  
  3572.     // This function returns the size of the tessellated mesh given a tessellation level.
  3573.     // This assumes uniform tessellation. For adaptive tessellation the Adaptive parameter must
  3574.     // be set to TRUE and TessellationLevel should be the max tessellation.
  3575.     // This will result in the max mesh size necessary for adaptive tessellation.
  3576.     function GetTessSize(fTessLevel: Single; Adaptive: LongBool; out NumTriangles, NumVertices: DWORD): HResult; stdcall;
  3577.  
  3578.     //GenerateAdjacency determines which patches are adjacent with provided tolerance
  3579.     //this information is used internally to optimize tessellation
  3580.     function GenerateAdjacency(Tolerance: Single): HResult; stdcall;
  3581.  
  3582.     //CloneMesh Creates a new patchmesh with the specified decl, and converts the vertex buffer
  3583.     //to the new decl. Entries in the new decl which are new are set to 0. If the current mesh
  3584.     //has adjacency, the new mesh will also have adjacency
  3585.     function CloneMesh(Options: DWORD; pDecl: PD3DVertexElement9; out pMesh: ID3DXPatchMesh): HResult; stdcall;
  3586.  
  3587.     // Optimizes the patchmesh for efficient tessellation. This function is designed
  3588.     // to perform one time optimization for patch meshes that need to be tessellated
  3589.     // repeatedly by calling the Tessellate() method. The optimization performed is
  3590.     // independent of the actual tessellation level used.
  3591.     // Currently Flags is unused.
  3592.     // If vertices are changed, Optimize must be called again
  3593.     function Optimize(flags: DWORD): HResult; stdcall;
  3594.  
  3595.     //gets and sets displacement parameters
  3596.     //displacement maps can only be 2D textures MIP-MAPPING is ignored for non adapative tessellation
  3597.     function SetDisplaceParam(Texture: IDirect3DBaseTexture9;
  3598.                               MinFilter: TD3DTextureFilterType;
  3599.                               MagFilter: TD3DTextureFilterType;
  3600.                               MipFilter: TD3DTextureFilterType;
  3601.                               Wrap: TD3DTextureAddress;
  3602.                               dwLODBias: DWORD): HResult; stdcall;
  3603.  
  3604.     function GetDisplaceParam(out Texture: IDirect3DBaseTexture9;
  3605.                               out MinFilter: TD3DTextureFilterType;
  3606.                               out MagFilter: TD3DTextureFilterType;
  3607.                               out MipFilter: TD3DTextureFilterType;
  3608.                               out Wrap: TD3DTextureAddress;
  3609.                               out dwLODBias: DWORD): HResult; stdcall;
  3610.         
  3611.     // Performs the uniform tessellation based on the tessellation level. 
  3612.     // This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call.
  3613.     function Tessellate(fTessLevel: Single; pMesh: ID3DXMesh): HResult; stdcall;
  3614.  
  3615.     // Performs adaptive tessellation based on the Z based adaptive tessellation criterion.
  3616.     // pTrans specifies a 4D vector that is dotted with the vertices to get the per vertex
  3617.     // adaptive tessellation amount. Each edge is tessellated to the average of the criterion
  3618.     // at the 2 vertices it connects.
  3619.     // MaxTessLevel specifies the upper limit for adaptive tesselation.
  3620.     // This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call.
  3621.     function TessellateAdaptive(const pTrans: TD3DXVector4; dwMaxTessLevel, dwMinTessLevel: DWORD; pMesh: ID3DXMesh): HResult; stdcall;
  3622.   end;
  3623.  
  3624.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXSkinInfo);'}
  3625.   {$EXTERNALSYM ID3DXSkinInfo}
  3626.   ID3DXSkinInfo = interface(IUnknown)
  3627.     ['{0E7DBBF3-421A-4dd8-B738-A5DAC3A48767}']
  3628.     // Specify the which vertices do each bones influence and by how much
  3629.     function SetBoneInfluence(bone, numInfluences: DWORD; vertices: PDWORD; weights: PSingle): HResult; stdcall;
  3630.     function GetNumBoneInfluences(bone: DWORD): DWORD; stdcall;
  3631.     function GetBoneInfluence(bone: DWORD; vertices: PDWORD; weights: PSingle): HResult; stdcall;
  3632.     function GetMaxVertexInfluences(out maxVertexInfluences: DWORD): HResult; stdcall;
  3633.     function GetNumBones: DWORD; stdcall;
  3634.  
  3635.     // This gets the max face influences based on a triangle mesh with the specified index buffer
  3636.     function GetMaxFaceInfluences(pIB: IDirect3DIndexBuffer9; NumFaces: DWORD; out maxFaceInfluences:DWORD): HResult; stdcall;
  3637.  
  3638.     // Set min bone influence. Bone influences that are smaller than this are ignored
  3639.     function SetMinBoneInfluence(MinInfl: Single): HResult; stdcall;
  3640.     // Get min bone influence.
  3641.     function GetMinBoneInfluence: Single; stdcall;
  3642.  
  3643.     // Bone names are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object
  3644.     function SetBoneName(Bone: DWORD; pName: PAnsiChar): HResult; stdcall; // pName is copied to an internal string buffer
  3645.     function GetBoneName(Bone: DWORD): PAnsiChar; stdcall; // A pointer to an internal string buffer is returned. Do not free this.
  3646.  
  3647.     // Bone offset matrices are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object
  3648.     function SetBoneOffsetMatrix(Bone: DWORD; const pBoneTransform: TD3DXMatrix): HResult; stdcall; // pBoneTransform is copied to an internal buffer
  3649.     function GetBoneOffsetMatrix(Bone: DWORD): PD3DXMatrix; stdcall; // A pointer to an internal matrix is returned. Do not free this.
  3650.  
  3651.     // Clone a skin info object
  3652.     function Clone(out ppSkinInfo: ID3DXSkinInfo): HResult; stdcall;
  3653.  
  3654.     // Update bone influence information to match vertices after they are reordered. This should be called
  3655.     // if the target vertex buffer has been reordered externally.
  3656.     function Remap(NumVertices: DWORD; pVertexRemap: PDWORD): HResult; stdcall;
  3657.  
  3658.     // These methods enable the modification of the vertex layout of the vertices that will be skinned
  3659.     function SetFVF(FVF: DWORD): HResult; stdcall;
  3660.     function SetDeclaration(pDeclaration: PD3DVertexElement9): HResult; stdcall;
  3661.     function GetFVF: DWORD; stdcall;
  3662.     function GetDeclaration(Declaration: TFVFDeclaration): HResult; stdcall;
  3663.  
  3664.     // Apply SW skinning based on current pose matrices to the target vertices.
  3665.     function UpdateSkinnedMesh(
  3666.       pBoneTransforms: PD3DXMatrix;
  3667.       pBoneInvTransposeTransforms: PD3DXMatrix;
  3668.       pVerticesSrc: Pointer;
  3669.       pVerticesDst: Pointer): HResult; stdcall;
  3670.  
  3671.     // Takes a mesh and returns a new mesh with per vertex blend weights and a bone combination
  3672.     // table that describes which bones affect which subsets of the mesh
  3673.     function ConvertToBlendedMesh(
  3674.       pMesh: ID3DXMesh;
  3675.       Options: DWORD;
  3676.       pAdjacencyIn: PDWORD;
  3677.       pAdjacencyOut: PDWORD;
  3678.       pFaceRemap: PDWORD;
  3679.       ppVertexRemap: PID3DXBuffer;
  3680.       pMaxFaceInfl: PDWORD;
  3681.       out pNumBoneCombinations: DWORD;
  3682.       out ppBoneCombinationTable: ID3DXBuffer;
  3683.       out ppMesh: ID3DXMesh): HResult; stdcall;
  3684.  
  3685.     // Takes a mesh and returns a new mesh with per vertex blend weights and indices 
  3686.     // and a bone combination table that describes which bones palettes affect which subsets of the mesh
  3687.     function ConvertToIndexedBlendedMesh(
  3688.       pMesh: ID3DXMesh;
  3689.       Options: DWORD;
  3690.       paletteSize: DWORD;
  3691.       pAdjacencyIn: PDWORD;
  3692.       pAdjacencyOut: PDWORD;
  3693.       pFaceRemap: PDWORD;
  3694.       ppVertexRemap: PID3DXBuffer;
  3695.       pMaxVertexInfl: PDWORD;
  3696.       out pNumBoneCombinations: DWORD;
  3697.       out ppBoneCombinationTable: ID3DXBuffer;
  3698.       out ppMesh: ID3DXMesh): HResult; stdcall;
  3699.   end;
  3700.  
  3701. type
  3702.   IID_ID3DXBaseMesh     = ID3DXBaseMesh;
  3703.   {$EXTERNALSYM IID_ID3DXBaseMesh}
  3704.   IID_ID3DXMesh         = ID3DXMesh;
  3705.   {$EXTERNALSYM IID_ID3DXMesh}
  3706.   IID_ID3DXPMesh        = ID3DXPMesh;
  3707.   {$EXTERNALSYM IID_ID3DXPMesh}
  3708.   IID_ID3DXSPMesh       = ID3DXSPMesh;
  3709.   {$EXTERNALSYM IID_ID3DXSPMesh}
  3710.   IID_ID3DXSkinInfo     = ID3DXSkinInfo;
  3711.   {$EXTERNALSYM IID_ID3DXSkinInfo}
  3712.   IID_ID3DXPatchMesh    = ID3DXPatchMesh;
  3713.   {$EXTERNALSYM IID_ID3DXPatchMesh}
  3714.  
  3715.  
  3716. function D3DXCreateMesh(NumFaces, NumVertices: DWord; Options: DWord;
  3717.   pDeclaration: PD3DVertexElement9;
  3718.   pD3D: IDirect3DDevice9; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx9meshDLL;
  3719. {$EXTERNALSYM D3DXCreateMesh}
  3720.  
  3721. function D3DXCreateMeshFVF(NumFaces, NumVertices: DWord; Options: DWord;
  3722.   FVF: DWord; pD3D: IDirect3DDevice9; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx9meshDLL;
  3723. {$EXTERNALSYM D3DXCreateMeshFVF}
  3724.  
  3725. function D3DXCreateSPMesh(pMesh: ID3DXMesh; pAdjacency: PDWord;
  3726.   pVertexAttributeWeights: PD3DXAttributeWeights; pVertexWeights: PSingle;
  3727.   out ppSMesh: ID3DXSPMesh): HResult; stdcall; external d3dx9meshDLL;
  3728. {$EXTERNALSYM D3DXCreateSPMesh}
  3729.  
  3730. // clean a mesh up for simplification, try to make manifold
  3731. function D3DXCleanMesh(pMeshIn: ID3DXMesh; pAdjacencyIn: PDWord;
  3732.   out ppMeshOut: ID3DXMesh; pAdjacencyOut: PDWord;
  3733.   ppErrorsAndWarnings: PID3DXBuffer): HResult; stdcall; external d3dx9meshDLL;
  3734. {$EXTERNALSYM D3DXCleanMesh}
  3735.  
  3736. function D3DXValidMesh(pMeshIn: ID3DXMesh; pAdjacency: PDWord;
  3737.   ppErrorsAndWarnings: PID3DXBuffer): HResult; stdcall; external d3dx9meshDLL;
  3738. {$EXTERNALSYM D3DXValidMesh}
  3739.  
  3740. function D3DXGeneratePMesh(pMesh: ID3DXMesh; pAdjacency: PDWord;
  3741.   pVertexAttributeWeights: PD3DXAttributeWeights; pVertexWeights: PSingle;
  3742.   MinValue: DWord; Options: TD3DMeshSimp; out ppPMesh: ID3DXPMesh): HResult; stdcall; external d3dx9meshDLL;
  3743. {$EXTERNALSYM D3DXGeneratePMesh}
  3744.  
  3745. function D3DXSimplifyMesh(pMesh: ID3DXMesh; pAdjacency: PDWord;
  3746.   pVertexAttributeWeights: PD3DXAttributeWeights; pVertexWeights: PSingle;
  3747.   MinValue: DWord; Options: TD3DMeshSimp; out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx9meshDLL;
  3748. {$EXTERNALSYM D3DXSimplifyMesh}
  3749.  
  3750. function D3DXComputeBoundingSphere(
  3751.   pFirstPosition: PD3DXVector3;       // pointer to first position
  3752.   NumVertices: DWORD;
  3753.   dwStride: DWORD;                     // count in bytes to subsequent position vectors
  3754.   out pCenter: TD3DXVector3;
  3755.   out pRadius: Single): HResult; stdcall; external d3dx9meshDLL;
  3756. {$EXTERNALSYM D3DXComputeBoundingSphere}
  3757.  
  3758. function D3DXComputeBoundingBox(
  3759.   pFirstPosition: PD3DXVector3;       // pointer to first position
  3760.   NumVertices: DWORD;
  3761.   dwStride: DWORD;                     // count in bytes to subsequent position vectors
  3762.   out pMin, pMax: TD3DXVector3): HResult; stdcall; external d3dx9meshDLL;
  3763. {$EXTERNALSYM D3DXComputeBoundingBox}
  3764.  
  3765. function D3DXComputeNormals(pMesh: ID3DXBaseMesh; pAdjacency: PDWord): HResult; stdcall; external d3dx9meshDLL;
  3766. {$EXTERNALSYM D3DXComputeNormals}
  3767.  
  3768. function D3DXCreateBuffer(NumBytes: DWord; out ppBuffer: ID3DXBuffer): HResult; stdcall; external d3dx9meshDLL;
  3769. {$EXTERNALSYM D3DXCreateBuffer}
  3770.  
  3771. function D3DXLoadMeshFromXA(
  3772.   pFilename: PAnsiChar;
  3773.   Options: DWord;
  3774.   pD3D: IDirect3DDevice9;
  3775.   ppAdjacency, ppMaterials, ppEffectInstances: PID3DXBuffer;
  3776.   pNumMaterials: PDWORD;
  3777.   out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx9meshDLL name 'D3DXLoadMeshFromXA';
  3778. {$EXTERNALSYM D3DXLoadMeshFromXA}
  3779.  
  3780. function D3DXLoadMeshFromXW(
  3781.   pFilename: PWideChar;
  3782.   Options: DWord;
  3783.   pD3D: IDirect3DDevice9;
  3784.   ppAdjacency, ppMaterials, ppEffectInstances: PID3DXBuffer;
  3785.   pNumMaterials: PDWORD;
  3786.   out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx9meshDLL name 'D3DXLoadMeshFromXW';
  3787. {$EXTERNALSYM D3DXLoadMeshFromXW}
  3788.  
  3789. function D3DXLoadMeshFromX(
  3790.   pFilename: PChar;
  3791.   Options: DWord;
  3792.   pD3D: IDirect3DDevice9;
  3793.   ppAdjacency, ppMaterials, ppEffectInstances: PID3DXBuffer;
  3794.   pNumMaterials: PDWORD;
  3795.   out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx9meshDLL name 'D3DXLoadMeshFromXA';
  3796. {$EXTERNALSYM D3DXLoadMeshFromX}
  3797.  
  3798.  
  3799. function D3DXLoadMeshFromXInMemory(
  3800.   Memory: Pointer;
  3801.   SizeOfMemory: DWORD;
  3802.   Options: DWORD;
  3803.   pD3D: IDirect3DDevice9;
  3804.   ppAdjacency, ppMaterials, ppEffectInstances: PID3DXBuffer;
  3805.   pNumMaterials: PDWORD;
  3806.   out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx9meshDLL;
  3807. {$EXTERNALSYM D3DXLoadMeshFromXInMemory}
  3808.  
  3809. function D3DXLoadMeshFromXResource(
  3810.   Module: HModule;
  3811.   Name: PAnsiChar;
  3812.   _Type: PAnsiChar;
  3813.   Options: DWORD;
  3814.   pD3D: IDirect3DDevice9;
  3815.   ppAdjacency, ppMaterials, ppEffectInstances: PID3DXBuffer;
  3816.   pNumMaterials: PDWORD;
  3817.   out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx9meshDLL;
  3818. {$EXTERNALSYM D3DXLoadMeshFromXResource}
  3819.  
  3820. function D3DXSaveMeshToXA(
  3821.   pFilename: PAnsiChar;
  3822.   pMesh: ID3DXMesh;
  3823.   pAdjacency: PDWORD;
  3824.   pMaterials: PD3DXMaterial;
  3825.   pEffectInstances: PD3DXEffectInstance;
  3826.   NumMaterials: DWORD;
  3827.   Format: DWORD): HResult; stdcall; external d3dx9meshDLL name 'D3DXSaveMeshToXA';
  3828. {$EXTERNALSYM D3DXSaveMeshToXA}
  3829.  
  3830. function D3DXSaveMeshToXW(
  3831.   pFilename: PWideChar;
  3832.   pMesh: ID3DXMesh;
  3833.   pAdjacency: PDWORD;
  3834.   pMaterials: PD3DXMaterial;
  3835.   pEffectInstances: PD3DXEffectInstance;
  3836.   NumMaterials: DWORD;
  3837.   Format: DWORD): HResult; stdcall; external d3dx9meshDLL name 'D3DXSaveMeshToXW';
  3838. {$EXTERNALSYM D3DXSaveMeshToXW}
  3839.  
  3840. function D3DXSaveMeshToX(
  3841.   pFilename: PChar;
  3842.   pMesh: ID3DXMesh;
  3843.   pAdjacency: PDWORD;
  3844.   pMaterials: PD3DXMaterial;
  3845.   pEffectInstances: PD3DXEffectInstance;
  3846.   NumMaterials: DWORD;
  3847.   Format: DWORD): HResult; stdcall; external d3dx9meshDLL name 'D3DXSaveMeshToXA';
  3848. {$EXTERNALSYM D3DXSaveMeshToX}
  3849.  
  3850.  
  3851. function D3DXCreatePMeshFromStream(
  3852.   pStream: IStream;
  3853.   Options: DWORD;
  3854.   pD3DDevice: IDirect3DDevice9;
  3855.   ppMaterials: PID3DXBuffer;
  3856.   ppEffectInstances: PID3DXBuffer;
  3857.   pNumMaterials: PDWORD;
  3858.   out ppPMesh: ID3DXPMesh): HResult; stdcall; external d3dx9meshDLL;
  3859. {$EXTERNALSYM D3DXCreatePMeshFromStream}
  3860.  
  3861. // Creates a skin info object based on the number of vertices, number of bones, and a declaration describing the vertex layout of the target vertices
  3862. // The bone names and initial bone transforms are not filled in the skin info object by this method.
  3863. function D3DXCreateSkinInfo(
  3864.   NumVertices: DWORD;
  3865.   pDeclaration: PD3DVertexElement9;
  3866.   NumBones: DWORD;
  3867.   out ppSkinInfo: ID3DXSkinInfo): HResult; stdcall; external d3dx9meshDLL;
  3868. {$EXTERNALSYM D3DXCreateSkinInfo}
  3869.  
  3870. // Creates a skin info object based on the number of vertices, number of bones, and a FVF describing the vertex layout of the target vertices
  3871. // The bone names and initial bone transforms are not filled in the skin info object by this method.
  3872. function D3DXCreateSkinInfoFVF(
  3873.   NumVertices: DWORD;
  3874.   FVF: DWORD;
  3875.   NumBones: DWORD;
  3876.   out ppSkinInfo: ID3DXSkinInfo): HResult; stdcall; external d3dx9meshDLL;
  3877. {$EXTERNALSYM D3DXCreateSkinInfoFVF}
  3878.  
  3879. function D3DXLoadMeshFromXof(
  3880.   pXofObjMesh: IDirectXFileData;
  3881.   Options: DWord;
  3882.   pD3D: IDirect3DDevice9;
  3883.   ppAdjacency, ppMaterials, ppEffectInstances: PID3DXBuffer;
  3884.   pNumMaterials: PDWord;
  3885.   out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx9meshDLL;
  3886. {$EXTERNALSYM D3DXLoadMeshFromXof}
  3887.  
  3888. // This similar to D3DXLoadMeshFromXof, except also returns skinning info if present in the file
  3889. // If skinning info is not present, ppSkinInfo will be NULL
  3890. function D3DXLoadSkinMeshFromXof(
  3891.   pXofObjMesh: IDirectXFileData;
  3892.   Options: DWORD;
  3893.   pD3D: IDirect3DDevice9;
  3894.   ppAdjacency, ppMaterials, ppEffectInstances: PID3DXBuffer;
  3895.   pMatOut: PDWORD;
  3896.   out ppSkinInfo: ID3DXSkinInfo;
  3897.   out ppMesh: ID3DXMesh): HResult; stdcall; external d3dx9meshDLL;
  3898. {$EXTERNALSYM D3DXLoadSkinMeshFromXof}
  3899.  
  3900. // The inverse of D3DXConvertTo{Indexed}BlendedMesh() functions. It figures out the skinning info from
  3901. // the mesh and the bone combination table and populates a skin info object with that data. The bone
  3902. // names and initial bone transforms are not filled in the skin info object by this method. This works
  3903. // with either a non-indexed or indexed blended mesh. It examines the FVF or declarator of the mesh to
  3904. // determine what type it is.
  3905. function D3DXCreateSkinInfoFromBlendedMesh(
  3906.   pMesh: ID3DXBaseMesh;
  3907.   NumBoneCombinations: DWORD;
  3908.   pBoneCombinationTable: PD3DXBoneCombination;
  3909.   out ppSkinInfo: ID3DXSkinInfo): HResult; stdcall; external d3dx9meshDLL;
  3910. {$EXTERNALSYM D3DXCreateSkinInfoFromBlendedMesh}
  3911.  
  3912. function D3DXTessellateNPatches(pMeshIn: ID3DXMesh;
  3913.   pAdjacencyIn: PDWord; NumSegs: Single;
  3914.   QuadraticInterpNormals: BOOL; // if false use linear intrep for normals, if true use quadratic
  3915.   out ppMeshOut: ID3DXMesh; ppAdjacencyOut: PDWord): HResult; stdcall; external d3dx9meshDLL;
  3916. {$EXTERNALSYM D3DXTessellateNPatches}
  3917.  
  3918.  
  3919. //generates implied outputdecl from input decl
  3920. //the decl generated from this should be used to generate the output decl for
  3921. //the tessellator subroutines.
  3922.  
  3923. function D3DXGenerateOutputDecl(
  3924.   pOutput: PD3DVertexElement9;
  3925.   pInput: PD3DVertexElement9): HResult; stdcall; external d3dx9meshDLL;
  3926. {$EXTERNALSYM D3DXGenerateOutputDecl}
  3927.  
  3928. //loads patches from an XFileData
  3929. //since an X file can have up to 6 different patch meshes in it,
  3930. //returns them in an array - pNumPatches will contain the number of
  3931. //meshes in the actual file.
  3932. function D3DXLoadPatchMeshFromXof(
  3933.   pXofObjMesh: IDirectXFileData;
  3934.   Options: DWORD;
  3935.   pDevice: IDirect3DDevice9;
  3936.   ppMaterials: PID3DXBuffer;
  3937.   ppEffectInstances: PID3DXBuffer;
  3938.   pNumMaterials: PDWORD;
  3939.   out ppMesh: ID3DXPatchMesh): HResult; stdcall; external d3dx9meshDLL;
  3940. {$EXTERNALSYM D3DXLoadPatchMeshFromXof}
  3941.  
  3942. //computes the size a single rect patch.
  3943. function D3DXRectPatchSize(
  3944.   pfNumSegs: PSingle;           //segments for each edge (4)
  3945.   pdwTriangles: PDWORD;         //output number of triangles
  3946.   pdwVertices: PDWORD           //output number of vertices
  3947.  ): HResult; stdcall; external d3dx9meshDLL;
  3948. {$EXTERNALSYM D3DXRectPatchSize}
  3949.  
  3950. //computes the size of a single triangle patch
  3951. function D3DXTriPatchSize(
  3952.   pfNumSegs: PSingle;           //segments for each edge (3)
  3953.   pdwTriangles: PDWORD;         //output number of triangles
  3954.   pdwVertices: PDWORD           //output number of vertices
  3955.  ): HResult; stdcall; external d3dx9meshDLL;
  3956. {$EXTERNALSYM D3DXTriPatchSize}
  3957.  
  3958.  
  3959. //tessellates a patch into a created mesh
  3960. //similar to D3D RT patch
  3961. function D3DXTessellateRectPatch(
  3962.   pVB: IDirect3DVertexBuffer9;
  3963.   pNumSegs: PSingle;
  3964.   pdwInDecl: PD3DVertexElement9;
  3965.   const pRectPatchInfo: TD3DRectPatchInfo;
  3966.   pMesh: ID3DXMesh): HResult; stdcall; external d3dx9meshDLL;
  3967. {$EXTERNALSYM D3DXTessellateRectPatch}
  3968.  
  3969.  
  3970. function D3DXTessellateTriPatch(
  3971.   pVB: IDirect3DVertexBuffer9;
  3972.   pNumSegs: PSingle;
  3973.   pInDecl: PD3DVertexElement9;
  3974.   pTriPatchInfo: TD3DTriPatchInfo;
  3975.   pMesh: ID3DXMesh): HResult; stdcall; external d3dx9meshDLL;
  3976. {$EXTERNALSYM D3DXTessellateTriPatch}
  3977.  
  3978.  
  3979.  
  3980. //creates an NPatch PatchMesh from a D3DXMESH
  3981. function D3DXCreateNPatchMesh(
  3982.   pMeshSysMem: ID3DXMesh;
  3983.   out pPatchMesh: ID3DXPatchMesh): HResult; stdcall; external d3dx9meshDLL;
  3984. {$EXTERNALSYM D3DXCreateNPatchMesh}
  3985.  
  3986.  
  3987. //creates a patch mesh
  3988. function D3DXCreatePatchMesh(
  3989.   const pInfo: TD3DXPatchInfo; //patch type
  3990.   dwNumPatches: DWORD;         //number of patches
  3991.   dwNumVertices: DWORD;        //number of control vertices
  3992.   dwOptions: DWORD;            //options
  3993.   pDecl: PD3DVertexElement9;   //format of control vertices
  3994.   pDevice: IDirect3DDevice9;
  3995.   out pPatchMesh: ID3DXPatchMesh): HResult; stdcall; external d3dx9meshDLL;
  3996. {$EXTERNALSYM D3DXCreatePatchMesh}
  3997.  
  3998.  
  3999. //returns the number of degenerates in a patch mesh -
  4000. //text output put in string.
  4001. function D3DXValidPatchMesh(
  4002.   pMesh: ID3DXPatchMesh;
  4003.   dwcDegenerateVertices: PDWORD;
  4004.   dwcDegeneratePatches: PDWORD;
  4005.   ppErrorsAndWarnings: PID3DXBuffer): HResult; stdcall; external d3dx9meshDLL;
  4006. {$EXTERNALSYM D3DXValidPatchMesh}
  4007.  
  4008. function D3DXGetFVFVertexSize(FVF: DWord): LongWord; stdcall; external d3dx9meshDLL;
  4009. {$EXTERNALSYM D3DXGetFVFVertexSize}
  4010.  
  4011. function D3DXGetDeclVertexSize(pDecl: PD3DVertexElement9; Stream: DWORD): LongWord; stdcall; external d3dx9meshDLL;
  4012. {$EXTERNALSYM D3DXGetDeclVertexSize}
  4013.  
  4014. function D3DXGetDeclLength(pDecl: PD3DVertexElement9): LongWord; stdcall; external d3dx9meshDLL;
  4015. {$EXTERNALSYM D3DXGetDeclLength}
  4016.  
  4017. function D3DXDeclaratorFromFVF(FVF: DWord; out Declaration: TFVFDeclaration): HResult; stdcall; external d3dx9meshDLL;
  4018. {$EXTERNALSYM D3DXDeclaratorFromFVF}
  4019.  
  4020. function D3DXFVFFromDeclarator(pDeclarator: PD3DVertexElement9; out pFVF: DWord): HResult; stdcall; external d3dx9meshDLL;
  4021. {$EXTERNALSYM D3DXFVFFromDeclarator}
  4022.  
  4023. function D3DXWeldVertices(
  4024.   pMesh: ID3DXMesh;
  4025.   Flags: DWORD;
  4026.   pEpsilons: PD3DXWeldEpsilons;
  4027.   rgdwAdjacencyIn, rgdwAdjacencyOut, pFaceRemap: PDWord;
  4028.   ppVertexRemap: PID3DXBuffer): HResult; stdcall; external d3dx9meshDLL;
  4029. {$EXTERNALSYM D3DXWeldVertices}
  4030.  
  4031. type
  4032.   PD3DXIntersectInfo = ^TD3DXIntersectInfo;
  4033.   _D3DXINTERSECTINFO = packed record
  4034.     FaceIndex: DWord;                // index of face intersected
  4035.     U: Single;                       // Barycentric Hit Coordinates
  4036.     V: Single;                       // Barycentric Hit Coordinates
  4037.     Dist: Single;                    // Ray-Intersection Parameter Distance
  4038.   end;
  4039.   {$EXTERNALSYM _D3DXINTERSECTINFO}
  4040.   D3DXINTERSECTINFO = _D3DXINTERSECTINFO;
  4041.   {$EXTERNALSYM D3DXINTERSECTINFO}
  4042.   TD3DXIntersectInfo = _D3DXINTERSECTINFO;
  4043.  
  4044. function D3DXIntersect(pMesh: ID3DXBaseMesh;
  4045.   const pRayPos, pRayDir: TD3DXVector3;
  4046.   out pHit: BOOL;                   // True if any faces were intersected
  4047.   pFaceIndex: PDWord;               // index of closest face intersected
  4048.   pU: PSingle;                      // Barycentric Hit Coordinates
  4049.   pV: PSingle;                      // Barycentric Hit Coordinates
  4050.   pDist: PSingle;                   // Ray-Intersection Parameter Distance
  4051.   ppAllHits: PID3DXBuffer;          // Array of D3DXINTERSECTINFOs for all hits (not just closest)
  4052.   pCountOfHits: PDWord              // Number of entries in AllHits array
  4053.  ): HResult; stdcall; external d3dx9meshDLL;
  4054. {$EXTERNALSYM D3DXIntersect}
  4055.  
  4056. function D3DXIntersectSubset(pMesh: ID3DXBaseMesh; AttribId: DWord;
  4057.   const pRayPos, pRayDir: TD3DXVector3;
  4058.   out pHit: BOOL;                   // True if any faces were intersected
  4059.   pFaceIndex: PDWord;               // index of closest face intersected
  4060.   pU: PSingle;                      // Barycentric Hit Coordinates
  4061.   pV: PSingle;                      // Barycentric Hit Coordinates
  4062.   pDist: PSingle;                   // Ray-Intersection Parameter Distance
  4063.   ppAllHits: PID3DXBuffer;          // Array of D3DXINTERSECTINFOs for all hits (not just closest)
  4064.   pCountOfHits: PDWord              // Number of entries in AllHits array
  4065.  ): HResult; stdcall; external d3dx9meshDLL;
  4066. {$EXTERNALSYM D3DXIntersectSubset}
  4067.  
  4068.  
  4069. function D3DXSplitMesh(pMeshIn: ID3DXMesh; pAdjacencyIn: PDWord;
  4070.   MaxSize, Options: DWord;
  4071.   out pMeshesOut: DWord; out ppMeshArrayOut: ID3DXBuffer;
  4072.   ppAdjacencyArrayOut, ppFaceRemapArrayOut, ppVertRemapArrayOut: PID3DXBuffer
  4073.  ): HResult; stdcall; external d3dx9meshDLL;
  4074. {$EXTERNALSYM D3DXSplitMesh}
  4075.  
  4076. function D3DXIntersectTri(
  4077.     const p0: TD3DXVector3;           // Triangle vertex 0 position
  4078.     const p1: TD3DXVector3;           // Triangle vertex 1 position
  4079.     const p2: TD3DXVector3;           // Triangle vertex 2 position
  4080.     const pRayPos: TD3DXVector3;      // Ray origin
  4081.     const pRayDir: TD3DXVector3;      // Ray direction
  4082.     out pU: Single;                   // Barycentric Hit Coordinates
  4083.     out pV: Single;                   // Barycentric Hit Coordinates
  4084.     out pDist: Single                 // Ray-Intersection Parameter Distance
  4085.  ): HResult; stdcall; external d3dx9meshDLL;
  4086. {$EXTERNALSYM D3DXIntersectTri}
  4087.  
  4088. function D3DXSphereBoundProbe(const pCenter: TD3DXVector3; Radius: Single;
  4089.   out pRayPosition, pRayDirection: TD3DXVector3): BOOL; stdcall; external d3dx9meshDLL;
  4090. {$EXTERNALSYM D3DXSphereBoundProbe}
  4091.  
  4092. function D3DXBoxBoundProbe(const pMin, pMax: TD3DXVector3;
  4093.   out pRayPosition, pRayDirection: TD3DXVector3): BOOL; stdcall; external d3dx9meshDLL;
  4094. {$EXTERNALSYM D3DXBoxBoundProbe}
  4095.  
  4096.  
  4097.  
  4098. //D3DXComputeTangent
  4099. //
  4100. //Computes the Tangent vectors for the TexStage texture coordinates
  4101. //and places the results in the TANGENT[TangentIndex] specified in the meshes' DECL
  4102. //puts the binorm in BINORM[BinormIndex] also specified in the decl.
  4103. //
  4104. //If neither the binorm or the tangnet are in the meshes declaration,
  4105. //the function will fail. 
  4106. //
  4107. //If a tangent or Binorm field is in the Decl, but the user does not
  4108. //wish D3DXComputeTangent to replace them, then D3DX_DEFAULT specified
  4109. //in the TangentIndex or BinormIndex will cause it to ignore the specified 
  4110. //semantic.
  4111. //
  4112. //Wrap should be specified if the texture coordinates wrap.
  4113.  
  4114. function D3DXComputeTangent(
  4115.   Mesh: ID3DXMesh;
  4116.   TexStage: DWORD;
  4117.   TangentIndex: DWORD;
  4118.   BinormIndex: DWORD;
  4119.   Wrap: DWORD;
  4120.   Adjacency: PDWORD): HResult; stdcall; external d3dx9meshDLL;
  4121. {$EXTERNALSYM D3DXComputeTangent}
  4122.  
  4123. function D3DXConvertMeshSubsetToSingleStrip(
  4124.   MeshIn: ID3DXBaseMesh;
  4125.   AttribId: DWord;
  4126.   IBOptions: DWord;
  4127.   out ppIndexBuffer: IDirect3DIndexBuffer9;
  4128.   pNumIndices: PDWord): HResult; stdcall; external d3dx9meshDLL;
  4129. {$EXTERNALSYM D3DXConvertMeshSubsetToSingleStrip}
  4130.  
  4131. function D3DXConvertMeshSubsetToStrips(
  4132.   MeshIn: ID3DXBaseMesh;
  4133.   AttribId: DWord;
  4134.   IBOptions: DWord;
  4135.   out ppIndexBuffer: IDirect3DIndexBuffer9;
  4136.   pNumIndices: PDWord;
  4137.   ppStripLengths: PID3DXBuffer;
  4138.   pNumStrips: PDWord): HResult; stdcall; external d3dx9meshDLL;
  4139. {$EXTERNALSYM D3DXConvertMeshSubsetToStrips}
  4140.  
  4141.  
  4142.  
  4143.  
  4144. //////////////////////////////////////////////////////////////////////////////
  4145. //
  4146. //  Definitions of .X file templates used by mesh load/save functions
  4147. //    that are not RM standard
  4148. //
  4149. //////////////////////////////////////////////////////////////////////////////
  4150.  
  4151. const
  4152.   DXFILEOBJ_XSkinMeshHeader: TGUID    = '{3CF169CE-FF7C-44ab-93C0-F78F62D172E2}';
  4153.   {$EXTERNALSYM DXFILEOBJ_XSkinMeshHeader}
  4154.   DXFILEOBJ_VertexDuplicationIndices: TGUID = '{B8D65549-D7C9-4995-89CF-53A9A8B031E3}';
  4155.   {$EXTERNALSYM DXFILEOBJ_VertexDuplicationIndices}
  4156.   DXFILEOBJ_FaceAdjacency: TGUID      = '{A64C844A-E282-4756-8B80-250CDE04398C}';
  4157.   {$EXTERNALSYM DXFILEOBJ_FaceAdjacency}
  4158.   DXFILEOBJ_SkinWeights: TGUID        = '{6F0D123B-BAD2-4167-A0D0-80224F25FABB}';
  4159.   {$EXTERNALSYM DXFILEOBJ_SkinWeights}
  4160.   DXFILEOBJ_Patch: TGUID              = '{A3EB5D44-FC22-429d-9AFB-3221CB9719A6}';
  4161.   {$EXTERNALSYM DXFILEOBJ_Patch}
  4162.   DXFILEOBJ_PatchMesh: TGUID          = '{D02C95CC-EDBA-4305-9B5D-1820D7704BBF}';
  4163.   {$EXTERNALSYM DXFILEOBJ_PatchMesh}
  4164.   DXFILEOBJ_PatchMesh9: TGUID         = '{B9EC94E1-B9A6-4251-BA18-94893F02C0EA}';
  4165.   {$EXTERNALSYM DXFILEOBJ_PatchMesh9}
  4166.   DXFILEOBJ_PMInfo: TGUID             = '{B6C3E656-EC8B-4b92-9B62-681659522947}';
  4167.   {$EXTERNALSYM DXFILEOBJ_PMInfo}
  4168.   DXFILEOBJ_PMAttributeRange: TGUID   = '{917E0427-C61E-4a14-9C64-AFE65F9E9844}';
  4169.   {$EXTERNALSYM DXFILEOBJ_PMAttributeRange}
  4170.   DXFILEOBJ_PMVSplitRecord: TGUID     = '{574CCC14-F0B3-4333-822D-93E8A8A08E4C}';
  4171.   {$EXTERNALSYM DXFILEOBJ_PMVSplitRecord}
  4172.   DXFILEOBJ_FVFData: TGUID            = '{B6E70A0E-8EF9-4e83-94AD-ECC8B0C04897}';
  4173.   {$EXTERNALSYM DXFILEOBJ_FVFData}
  4174.   DXFILEOBJ_VertexElement: TGUID      = '{F752461C-1E23-48f6-B9F8-8350850F336F}';
  4175.   {$EXTERNALSYM DXFILEOBJ_VertexElement}
  4176.   DXFILEOBJ_DeclData: TGUID           = '{BF22E553-292C-4781-9FEA-62BD554BDD93}';
  4177.   {$EXTERNALSYM DXFILEOBJ_DeclData}
  4178.   DXFILEOBJ_EffectFloats: TGUID       = '{F1CFE2B3-0DE3-4e28-AFA1-155A750A282D}';
  4179.   {$EXTERNALSYM DXFILEOBJ_EffectFloats}
  4180.   DXFILEOBJ_EffectString: TGUID       = '{D55B097E-BDB6-4c52-B03D-6051C89D0E42}';
  4181.   {$EXTERNALSYM DXFILEOBJ_EffectString}
  4182.   DXFILEOBJ_EffectDWord: TGUID        = '{622C0ED0-956E-4da9-908A-2AF94F3CE716}';
  4183.   {$EXTERNALSYM DXFILEOBJ_EffectDWord}
  4184.   DXFILEOBJ_EffectParamFloats: TGUID  = '{3014B9A0-62F5-478c-9B86-E4AC9F4E418B}';
  4185.   {$EXTERNALSYM DXFILEOBJ_EffectParamFloats}
  4186.   DXFILEOBJ_EffectParamString: TGUID  = '{1DBC4C88-94C1-46ee-9076-2C28818C9481}';
  4187.   {$EXTERNALSYM DXFILEOBJ_EffectParamString}
  4188.   DXFILEOBJ_EffectParamDWord: TGUID   = '{E13963BC-AE51-4c5d-B00F-CFA3A9D97CE5}';
  4189.   {$EXTERNALSYM DXFILEOBJ_EffectParamDWord}
  4190.   DXFILEOBJ_EffectInstance: TGUID     = '{E331F7E4-0559-4cc2-8E99-1CEC1657928F}';
  4191.   {$EXTERNALSYM DXFILEOBJ_EffectInstance}
  4192.   DXFILEOBJ_AnimTicksPerSecond: TGUID = '{9E415A43-7BA6-4a73-8743-B73D47E88476}';
  4193.   {$EXTERNALSYM DXFILEOBJ_AnimTicksPerSecond}
  4194.  
  4195. const
  4196.   XSKINEXP_TEMPLATES =
  4197.         'xof 0303txt 0032' +
  4198.         'template XSkinMeshHeader ' +
  4199.         '{ ' +
  4200.         '    <3CF169CE-FF7C-44ab-93C0-F78F62D172E2> ' +
  4201.         '    WORD nMaxSkinWeightsPerVertex; ' +
  4202.         '    WORD nMaxSkinWeightsPerFace; ' +
  4203.         '    WORD nBones; ' +
  4204.         '} ' +
  4205.         'template VertexDuplicationIndices ' +
  4206.         '{ ' +
  4207.         '    <B8D65549-D7C9-4995-89CF-53A9A8B031E3> ' +
  4208.         '    DWORD nIndices; ' +
  4209.         '    DWORD nOriginalVertices; ' +
  4210.         '    array DWORD indices[nIndices]; ' +
  4211.         '} ' +
  4212.         'template FaceAdjacency ' +
  4213.         '{ ' +
  4214.         '    <A64C844A-E282-4756-8B80-250CDE04398C> ' +
  4215.         '    DWORD nIndices; ' +
  4216.         '    array DWORD indices[nIndices]; ' +
  4217.         '} ' +
  4218.         'template SkinWeights ' +
  4219.         '{ ' +
  4220.         '    <6F0D123B-BAD2-4167-A0D0-80224F25FABB> ' +
  4221.         '    STRING transformNodeName; ' +
  4222.         '    DWORD nWeights; ' +
  4223.         '    array DWORD vertexIndices[nWeights]; ' +
  4224.         '    array float weights[nWeights]; ' +
  4225.         '    Matrix4x4 matrixOffset; ' +
  4226.         '} ' +
  4227.         'template Patch ' +
  4228.         '{ ' +
  4229.         '    <A3EB5D44-FC22-429D-9AFB-3221CB9719A6> ' +
  4230.         '    DWORD nControlIndices; ' +
  4231.         '    array DWORD controlIndices[nControlIndices]; ' +
  4232.         '} ' +
  4233.         'template PatchMesh ' +
  4234.         '{ ' +
  4235.         '    <D02C95CC-EDBA-4305-9B5D-1820D7704BBF> ' +
  4236.         '    DWORD nVertices; ' +
  4237.         '    array Vector vertices[nVertices]; ' +
  4238.         '    DWORD nPatches; ' +
  4239.         '    array Patch patches[nPatches]; ' +
  4240.         '    [ ... ] ' +
  4241.         '} ' +
  4242.         'template PatchMesh9 ' +
  4243.         '{ ' +
  4244.         '    <B9EC94E1-B9A6-4251-BA18-94893F02C0EA> ' +
  4245.         '    DWORD Type; ' +
  4246.         '    DWORD Degree; ' +
  4247.         '    DWORD Basis; ' +
  4248.         '    DWORD nVertices; ' +
  4249.         '    array Vector vertices[nVertices]; ' +
  4250.         '    DWORD nPatches; ' +
  4251.         '    array Patch patches[nPatches]; ' +
  4252.         '    [ ... ] ' +
  4253.         '} ' +
  4254.         'template EffectFloats ' +
  4255.         '{ ' +
  4256.         '    <F1CFE2B3-0DE3-4e28-AFA1-155A750A282D> ' +
  4257.         '    DWORD nFloats; ' +
  4258.         '    array float Floats[nFloats]; ' +
  4259.         '} ' +
  4260.         'template EffectString ' +
  4261.         '{ ' +
  4262.         '    <D55B097E-BDB6-4c52-B03D-6051C89D0E42> ' +
  4263.         '    STRING Value; ' +
  4264.         '} ' +
  4265.         'template EffectDWord ' +
  4266.         '{ ' +
  4267.         '    <622C0ED0-956E-4da9-908A-2AF94F3CE716> ' +
  4268.         '    DWORD Value; ' +
  4269.         '} ' +
  4270.         'template EffectParamFloats ' +
  4271.         '{ ' +
  4272.         '    <3014B9A0-62F5-478c-9B86-E4AC9F4E418B> ' +
  4273.         '    STRING ParamName; ' +
  4274.         '    DWORD nFloats; ' +
  4275.         '    array float Floats[nFloats]; ' +
  4276.         '} ' +
  4277.         'template EffectParamString ' +
  4278.         '{ ' +
  4279.         '    <1DBC4C88-94C1-46ee-9076-2C28818C9481> ' +
  4280.         '    STRING ParamName; ' +
  4281.         '    STRING Value; ' +
  4282.         '} ' +
  4283.         'template EffectParamDWord ' +
  4284.         '{ ' +
  4285.         '    <E13963BC-AE51-4c5d-B00F-CFA3A9D97CE5> ' +
  4286.         '    STRING ParamName; ' +
  4287.         '    DWORD Value; ' +
  4288.         '} ' +
  4289.         'template EffectInstance ' +
  4290.         '{ ' +
  4291.         '    <E331F7E4-0559-4cc2-8E99-1CEC1657928F> ' +
  4292.         '    STRING EffectFilename; ' +
  4293.         '    [ ... ] ' +
  4294.         '} ' +
  4295.         'template AnimTicksPerSecond ' +
  4296.         '{ ' +
  4297.         '    <9E415A43-7BA6-4a73-8743-B73D47E88476> ' +
  4298.         '    DWORD AnimTicksPerSecond; ' +
  4299.         '} ';
  4300.   {$EXTERNALSYM XSKINEXP_TEMPLATES}
  4301.  
  4302.   XEXTENSIONS_TEMPLATES =
  4303.         'xof 0303txt 0032' +
  4304.         'template FVFData ' +
  4305.         '{ ' +
  4306.         '    <B6E70A0E-8EF9-4e83-94AD-ECC8B0C04897> ' +
  4307.         '    DWORD dwFVF; ' +
  4308.         '    DWORD nDWords; ' +
  4309.         '    array DWORD data[nDWords]; ' +
  4310.         '} ' +
  4311.         'template VertexElement ' +
  4312.         '{ ' +
  4313.         '    <F752461C-1E23-48f6-B9F8-8350850F336F> ' +
  4314.         '    DWORD Type; ' +
  4315.         '    DWORD Method; ' +
  4316.         '    DWORD Usage; ' +
  4317.         '    DWORD UsageIndex; ' +
  4318.         '} ' +
  4319.         'template DeclData ' +
  4320.         '{ ' +
  4321.         '    <BF22E553-292C-4781-9FEA-62BD554BDD93> ' +
  4322.         '    DWORD nElements; ' +
  4323.         '    array VertexElement Elements[nElements]; ' +
  4324.         '    DWORD nDWords; ' +
  4325.         '    array DWORD data[nDWords]; ' +
  4326.         '} ' +
  4327.         'template PMAttributeRange ' +
  4328.         '{ ' +
  4329.         '    <917E0427-C61E-4a14-9C64-AFE65F9E9844> ' +
  4330.         '    DWORD iFaceOffset; ' +
  4331.         '    DWORD nFacesMin; ' +
  4332.         '    DWORD nFacesMax; ' +
  4333.         '    DWORD iVertexOffset; ' +
  4334.         '    DWORD nVerticesMin; ' +
  4335.         '    DWORD nVerticesMax; ' +
  4336.         '} ' +
  4337.         'template PMVSplitRecord ' +
  4338.         '{ ' +
  4339.         '    <574CCC14-F0B3-4333-822D-93E8A8A08E4C> ' +
  4340.         '    DWORD iFaceCLW; ' +
  4341.         '    DWORD iVlrOffset; ' +
  4342.         '    DWORD iCode; ' +
  4343.         '} ' +
  4344.         'template PMInfo ' +
  4345.         '{ ' +
  4346.         '    <B6C3E656-EC8B-4b92-9B62-681659522947> ' +
  4347.         '    DWORD nAttributes; ' +
  4348.         '    array PMAttributeRange attributeRanges[nAttributes]; ' +
  4349.         '    DWORD nMaxValence; ' +
  4350.         '    DWORD nMinLogicalVertices; ' +
  4351.         '    DWORD nMaxLogicalVertices; ' +
  4352.         '    DWORD nVSplits; ' +
  4353.         '    array PMVSplitRecord splitRecords[nVSplits]; ' +
  4354.         '    DWORD nAttributeMispredicts; ' +
  4355.         '    array DWORD attributeMispredicts[nAttributeMispredicts]; ' +
  4356.         '} ';
  4357.   {$EXTERNALSYM XEXTENSIONS_TEMPLATES}
  4358.  
  4359.  
  4360.  
  4361.  
  4362.  
  4363. ///////////////////////////////////////////////////////////////////////////
  4364. //
  4365. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  4366. //
  4367. //  File:       d3dx9shapes.h
  4368. //  Content:    D3DX simple shapes
  4369. //
  4370. ///////////////////////////////////////////////////////////////////////////
  4371.  
  4372.  
  4373. ///////////////////////////////////////////////////////////////////////////
  4374. // Functions:
  4375. ///////////////////////////////////////////////////////////////////////////
  4376.  
  4377.  
  4378. //-------------------------------------------------------------------------
  4379. // D3DXCreatePolygon:
  4380. // ------------------
  4381. // Creates a mesh containing an n-sided polygon.  The polygon is centered
  4382. // at the origin.
  4383. //
  4384. // Parameters:
  4385. //
  4386. //  pDevice     The D3D device with which the mesh is going to be used.
  4387. //  Length      Length of each side.
  4388. //  Sides       Number of sides the polygon has.  (Must be >= 3)
  4389. //  ppMesh      The mesh object which will be created
  4390. //  ppAdjacency Returns a buffer containing adjacency info.  Can be NULL.
  4391. //-------------------------------------------------------------------------
  4392. function D3DXCreatePolygon(ppDevice: IDirect3DDevice9;
  4393.   Length: Single;
  4394.   Sides: LongWord;
  4395.   out ppMesh: ID3DXMesh;
  4396.   ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx9shapesDLL;
  4397. {$EXTERNALSYM D3DXCreatePolygon}
  4398.  
  4399.  
  4400. //-------------------------------------------------------------------------
  4401. // D3DXCreateBox:
  4402. // --------------
  4403. // Creates a mesh containing an axis-aligned box.  The box is centered at
  4404. // the origin.
  4405. //
  4406. // Parameters:
  4407. //
  4408. //  pDevice     The D3D device with which the mesh is going to be used.
  4409. //  Width       Width of box (along X-axis)
  4410. //  Height      Height of box (along Y-axis)
  4411. //  Depth       Depth of box (along Z-axis)
  4412. //  ppMesh      The mesh object which will be created
  4413. //  ppAdjacency Returns a buffer containing adjacency info.  Can be NULL.
  4414. //-------------------------------------------------------------------------
  4415. function D3DXCreateBox(ppDevice: IDirect3DDevice9;
  4416.   Width,
  4417.   Height,
  4418.   Depth: Single;
  4419.   out ppMesh: ID3DXMesh;
  4420.   ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx9shapesDLL;
  4421. {$EXTERNALSYM D3DXCreateBox}
  4422.  
  4423.  
  4424. //-------------------------------------------------------------------------
  4425. // D3DXCreateCylinder:
  4426. // -------------------
  4427. // Creates a mesh containing a cylinder.  The generated cylinder is
  4428. // centered at the origin, and its axis is aligned with the Z-axis.
  4429. //
  4430. // Parameters:
  4431. //
  4432. //  pDevice     The D3D device with which the mesh is going to be used.
  4433. //  Radius1     Radius at -Z end (should be >= 0.0f)
  4434. //  Radius2     Radius at +Z end (should be >= 0.0f)
  4435. //  Length      Length of cylinder (along Z-axis)
  4436. //  Slices      Number of slices about the main axis
  4437. //  Stacks      Number of stacks along the main axis
  4438. //  ppMesh      The mesh object which will be created
  4439. //  ppAdjacency Returns a buffer containing adjacency info.  Can be NULL.
  4440. //-------------------------------------------------------------------------
  4441. function D3DXCreateCylinder(ppDevice: IDirect3DDevice9;
  4442.   Radius1,
  4443.   Radius2,
  4444.   Length: Single;
  4445.   Slices,
  4446.   Stacks: LongWord;
  4447.   out ppMesh: ID3DXMesh;
  4448.   ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx9shapesDLL;
  4449. {$EXTERNALSYM D3DXCreateCylinder}
  4450.  
  4451.  
  4452. //-------------------------------------------------------------------------
  4453. // D3DXCreateSphere:
  4454. // -----------------
  4455. // Creates a mesh containing a sphere.  The sphere is centered at the
  4456. // origin.
  4457. //
  4458. // Parameters:
  4459. //
  4460. //  pDevice     The D3D device with which the mesh is going to be used.
  4461. //  Radius      Radius of the sphere (should be >= 0.0f)
  4462. //  Slices      Number of slices about the main axis
  4463. //  Stacks      Number of stacks along the main axis
  4464. //  ppMesh      The mesh object which will be created
  4465. //  ppAdjacency Returns a buffer containing adjacency info.  Can be NULL.
  4466. //-------------------------------------------------------------------------
  4467. function D3DXCreateSphere(ppDevice: IDirect3DDevice9;
  4468.   Radius: Single;
  4469.   Slices,
  4470.   Stacks: LongWord;
  4471.   out ppMesh: ID3DXMesh;
  4472.   ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx9shapesDLL;
  4473. {$EXTERNALSYM D3DXCreateSphere}
  4474.  
  4475.  
  4476. //-------------------------------------------------------------------------
  4477. // D3DXCreateTorus:
  4478. // ----------------
  4479. // Creates a mesh containing a torus.  The generated torus is centered at
  4480. // the origin, and its axis is aligned with the Z-axis.
  4481. //
  4482. // Parameters:
  4483. //
  4484. //  pDevice     The D3D device with which the mesh is going to be used.
  4485. //  InnerRadius Inner radius of the torus (should be >= 0.0f)
  4486. //  OuterRadius Outer radius of the torue (should be >= 0.0f)
  4487. //  Sides       Number of sides in a cross-section (must be >= 3)
  4488. //  Rings       Number of rings making up the torus (must be >= 3)
  4489. //  ppMesh      The mesh object which will be created
  4490. //  ppAdjacency Returns a buffer containing adjacency info.  Can be NULL.
  4491. //-------------------------------------------------------------------------
  4492. function D3DXCreateTorus(ppDevice: IDirect3DDevice9;
  4493.   InnerRadius,
  4494.   OuterRadius: Single;
  4495.   Sides,
  4496.   Rings: LongWord;
  4497.   out ppMesh: ID3DXMesh;
  4498.   ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx9shapesDLL;
  4499. {$EXTERNALSYM D3DXCreateTorus}
  4500.  
  4501.  
  4502. //-------------------------------------------------------------------------
  4503. // D3DXCreateTeapot:
  4504. // -----------------
  4505. // Creates a mesh containing a teapot.
  4506. //
  4507. // Parameters:
  4508. //
  4509. //  pDevice     The D3D device with which the mesh is going to be used.
  4510. //  ppMesh      The mesh object which will be created
  4511. //  ppAdjacency Returns a buffer containing adjacency info.  Can be NULL.
  4512. //-------------------------------------------------------------------------
  4513. function D3DXCreateTeapot(ppDevice: IDirect3DDevice9;
  4514.   out ppMesh: ID3DXMesh;
  4515.   ppAdjacency: PID3DXBuffer): HResult; stdcall; external d3dx9shapesDLL;
  4516. {$EXTERNALSYM D3DXCreateTeapot}
  4517.  
  4518.  
  4519. //-------------------------------------------------------------------------
  4520. // D3DXCreateText:
  4521. // ---------------
  4522. // Creates a mesh containing the specified text using the font associated
  4523. // with the device context.
  4524. //
  4525. // Parameters:
  4526. //
  4527. //  pDevice       The D3D device with which the mesh is going to be used.
  4528. //  hDC           Device context, with desired font selected
  4529. //  pText         Text to generate
  4530. //  Deviation     Maximum chordal deviation from true font outlines
  4531. //  Extrusion     Amount to extrude text in -Z direction
  4532. //  ppMesh        The mesh object which will be created
  4533. //  pGlyphMetrics Address of buffer to receive glyph metric data (or NULL)
  4534. //-------------------------------------------------------------------------
  4535.  
  4536. function D3DXCreateTextA(ppDevice: IDirect3DDevice9;
  4537.   hDC: HDC;
  4538.   pText: PAnsiChar;
  4539.   Deviation: Single;
  4540.   Extrusion: Single;
  4541.   out ppMesh: ID3DXMesh;
  4542.   ppAdjacency: PID3DXBuffer;
  4543.   pGlyphMetrics: PGlyphMetricsFloat): HResult; stdcall; external d3dx9shapesDLL name 'D3DXCreateTextA';
  4544. {$EXTERNALSYM D3DXCreateTextA}
  4545.  
  4546. function D3DXCreateTextW(ppDevice: IDirect3DDevice9;
  4547.   hDC: HDC;
  4548.   pText: PWideChar;
  4549.   Deviation: Single;
  4550.   Extrusion: Single;
  4551.   out ppMesh: ID3DXMesh;
  4552.   ppAdjacency: PID3DXBuffer;
  4553.   pGlyphMetrics: PGlyphMetricsFloat): HResult; stdcall; external d3dx9shapesDLL name 'D3DXCreateTextW';
  4554. {$EXTERNALSYM D3DXCreateTextW}
  4555.  
  4556. function D3DXCreateText(ppDevice: IDirect3DDevice9;
  4557.   hDC: HDC;
  4558.   pText: PChar;
  4559.   Deviation: Single;
  4560.   Extrusion: Single;
  4561.   out ppMesh: ID3DXMesh;
  4562.   ppAdjacency: PID3DXBuffer;
  4563.   pGlyphMetrics: PGlyphMetricsFloat): HResult; stdcall; external d3dx9shapesDLL name 'D3DXCreateTextA';
  4564. {$EXTERNALSYM D3DXCreateText}
  4565.  
  4566.  
  4567.  
  4568.  
  4569.  
  4570.  
  4571.  
  4572. //////////////////////////////////////////////////////////////////////////////
  4573. //
  4574. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  4575. //
  4576. //  File:       d3dx9tex.h
  4577. //  Content:    D3DX texturing APIs
  4578. //
  4579. //////////////////////////////////////////////////////////////////////////////
  4580.  
  4581. //----------------------------------------------------------------------------
  4582. // D3DX_FILTER flags:
  4583. // ------------------
  4584. //
  4585. // A valid filter must contain one of these values:
  4586. //
  4587. //  D3DX_FILTER_NONE
  4588. //      No scaling or filtering will take place.  Pixels outside the bounds
  4589. //      of the source image are assumed to be transparent black.
  4590. //  D3DX_FILTER_POINT
  4591. //      Each destination pixel is computed by sampling the nearest pixel
  4592. //      from the source image.
  4593. //  D3DX_FILTER_LINEAR
  4594. //      Each destination pixel is computed by linearly interpolating between
  4595. //      the nearest pixels in the source image.  This filter works best
  4596. //      when the scale on each axis is less than 2.
  4597. //  D3DX_FILTER_TRIANGLE
  4598. //      Every pixel in the source image contributes equally to the
  4599. //      destination image.  This is the slowest of all the filters.
  4600. //  D3DX_FILTER_BOX
  4601. //      Each pixel is computed by averaging a 2x2(x2) box pixels from
  4602. //      the source image. Only works when the dimensions of the
  4603. //      destination are half those of the source. (as with mip maps)
  4604. //
  4605. // And can be OR'd with any of these optional flags:
  4606. //
  4607. //  D3DX_FILTER_MIRROR_U
  4608. //      Indicates that pixels off the edge of the texture on the U-axis
  4609. //      should be mirrored, not wraped.
  4610. //  D3DX_FILTER_MIRROR_V
  4611. //      Indicates that pixels off the edge of the texture on the V-axis
  4612. //      should be mirrored, not wraped.
  4613. //  D3DX_FILTER_MIRROR_W
  4614. //      Indicates that pixels off the edge of the texture on the W-axis
  4615. //      should be mirrored, not wraped.
  4616. //  D3DX_FILTER_MIRROR
  4617. //      Same as specifying D3DX_FILTER_MIRROR_U | D3DX_FILTER_MIRROR_V |
  4618. //      D3DX_FILTER_MIRROR_V
  4619. //  D3DX_FILTER_DITHER
  4620. //      Dithers the resulting image using a 4x4 order dither pattern.
  4621. //  D3DX_FILTER_SRGB_IN
  4622. //      Denotes that the input data is in sRGB (gamma 2.2) colorspace.
  4623. //  D3DX_FILTER_SRGB_OUT
  4624. //      Denotes that the output data is in sRGB (gamma 2.2) colorspace.
  4625. //  D3DX_FILTER_SRGB
  4626. //      Same as specifying D3DX_FILTER_SRGB_IN | D3DX_FILTER_SRGB_OUT
  4627. //
  4628. //----------------------------------------------------------------------------
  4629.  
  4630. const
  4631.   D3DX_FILTER_NONE      = (1 shl 0);
  4632.   {$EXTERNALSYM D3DX_FILTER_NONE}
  4633.   D3DX_FILTER_POINT     = (2 shl 0);
  4634.   {$EXTERNALSYM D3DX_FILTER_POINT}
  4635.   D3DX_FILTER_LINEAR    = (3 shl 0);
  4636.   {$EXTERNALSYM D3DX_FILTER_LINEAR}
  4637.   D3DX_FILTER_TRIANGLE  = (4 shl 0);
  4638.   {$EXTERNALSYM D3DX_FILTER_TRIANGLE}
  4639.   D3DX_FILTER_BOX       = (5 shl 0);
  4640.   {$EXTERNALSYM D3DX_FILTER_BOX}
  4641.  
  4642.   D3DX_FILTER_MIRROR_U  = (1 shl 16);
  4643.   {$EXTERNALSYM D3DX_FILTER_MIRROR_U}
  4644.   D3DX_FILTER_MIRROR_V  = (2 shl 16);
  4645.   {$EXTERNALSYM D3DX_FILTER_MIRROR_V}
  4646.   D3DX_FILTER_MIRROR_W  = (4 shl 16);
  4647.   {$EXTERNALSYM D3DX_FILTER_MIRROR_W}
  4648.   D3DX_FILTER_MIRROR    = (7 shl 16);
  4649.   {$EXTERNALSYM D3DX_FILTER_MIRROR}
  4650.   D3DX_FILTER_DITHER    = (1 shl 19);
  4651.   {$EXTERNALSYM D3DX_FILTER_DITHER}
  4652.   D3DX_FILTER_SRGB_IN   = (1 shl 20);
  4653.   {$EXTERNALSYM D3DX_FILTER_SRGB_IN}
  4654.   D3DX_FILTER_SRGB_OUT  = (2 shl 20);
  4655.   {$EXTERNALSYM D3DX_FILTER_SRGB_OUT}
  4656.   D3DX_FILTER_SRGB      = (3 shl 20);
  4657.   {$EXTERNALSYM D3DX_FILTER_SRGB}
  4658.  
  4659.  
  4660. //----------------------------------------------------------------------------
  4661. // D3DX_NORMALMAP flags:
  4662. // ---------------------
  4663. // These flags are used to control how D3DXComputeNormalMap generates normal
  4664. // maps.  Any number of these flags may be OR'd together in any combination.
  4665. //
  4666. //  D3DX_NORMALMAP_MIRROR_U
  4667. //      Indicates that pixels off the edge of the texture on the U-axis
  4668. //      should be mirrored, not wraped.
  4669. //  D3DX_NORMALMAP_MIRROR_V
  4670. //      Indicates that pixels off the edge of the texture on the V-axis
  4671. //      should be mirrored, not wraped.
  4672. //  D3DX_NORMALMAP_MIRROR
  4673. //      Same as specifying D3DX_NORMALMAP_MIRROR_U | D3DX_NORMALMAP_MIRROR_V
  4674. //  D3DX_NORMALMAP_INVERTSIGN
  4675. //      Inverts the direction of each normal
  4676. //  D3DX_NORMALMAP_COMPUTE_OCCLUSION
  4677. //      Compute the per pixel Occlusion term and encodes it into the alpha.
  4678. //      An Alpha of 1 means that the pixel is not obscured in anyway, and
  4679. //      an alpha of 0 would mean that the pixel is completly obscured.
  4680. //
  4681. //----------------------------------------------------------------------------
  4682.  
  4683. //----------------------------------------------------------------------------
  4684.  
  4685. const
  4686.   D3DX_NORMALMAP_MIRROR_U     = (1 shl 16);
  4687.   {$EXTERNALSYM D3DX_NORMALMAP_MIRROR_U}
  4688.   D3DX_NORMALMAP_MIRROR_V     = (2 shl 16);
  4689.   {$EXTERNALSYM D3DX_NORMALMAP_MIRROR_V}
  4690.   D3DX_NORMALMAP_MIRROR       = (3 shl 16);
  4691.   {$EXTERNALSYM D3DX_NORMALMAP_MIRROR}
  4692.   D3DX_NORMALMAP_INVERTSIGN   = (8 shl 16);
  4693.   {$EXTERNALSYM D3DX_NORMALMAP_INVERTSIGN}
  4694.   D3DX_NORMALMAP_COMPUTE_OCCLUSION = (16 shl 16);
  4695.   {$EXTERNALSYM D3DX_NORMALMAP_COMPUTE_OCCLUSION}
  4696.  
  4697.  
  4698. //----------------------------------------------------------------------------
  4699. // D3DX_CHANNEL flags:
  4700. // -------------------
  4701. // These flags are used by functions which operate on or more channels
  4702. // in a texture.
  4703. //
  4704. // D3DX_CHANNEL_RED
  4705. //     Indicates the red channel should be used
  4706. // D3DX_CHANNEL_BLUE
  4707. //     Indicates the blue channel should be used
  4708. // D3DX_CHANNEL_GREEN
  4709. //     Indicates the green channel should be used
  4710. // D3DX_CHANNEL_ALPHA
  4711. //     Indicates the alpha channel should be used
  4712. // D3DX_CHANNEL_LUMINANCE
  4713. //     Indicates the luminaces of the red green and blue channels should be
  4714. //     used.
  4715. //
  4716. //----------------------------------------------------------------------------
  4717.  
  4718. const
  4719.   D3DX_CHANNEL_RED            = (1 shl 0);
  4720.   {$EXTERNALSYM D3DX_CHANNEL_RED}
  4721.   D3DX_CHANNEL_BLUE           = (1 shl 1);
  4722.   {$EXTERNALSYM D3DX_CHANNEL_BLUE}
  4723.   D3DX_CHANNEL_GREEN          = (1 shl 2);
  4724.   {$EXTERNALSYM D3DX_CHANNEL_GREEN}
  4725.   D3DX_CHANNEL_ALPHA          = (1 shl 3);
  4726.   {$EXTERNALSYM D3DX_CHANNEL_ALPHA}
  4727.   D3DX_CHANNEL_LUMINANCE      = (1 shl 4);
  4728.   {$EXTERNALSYM D3DX_CHANNEL_LUMINANCE}
  4729.  
  4730.  
  4731. //----------------------------------------------------------------------------
  4732. // D3DXIMAGE_FILEFORMAT:
  4733. // ---------------------
  4734. // This enum is used to describe supported image file formats.
  4735. //
  4736. //----------------------------------------------------------------------------
  4737.  
  4738. type
  4739.   PD3DXImageFileFormat = ^TD3DXImageFileFormat;
  4740.   _D3DXIMAGE_FILEFORMAT = (
  4741.     D3DXIFF_BMP        {= 0},
  4742.     D3DXIFF_JPG        {= 1},
  4743.     D3DXIFF_TGA        {= 2},
  4744.     D3DXIFF_PNG        {= 3},
  4745.     D3DXIFF_DDS        {= 4},
  4746.     D3DXIFF_PPM        {= 5},
  4747.     D3DXIFF_DIB        {= 6}
  4748.   );
  4749.   {$EXTERNALSYM _D3DXIMAGE_FILEFORMAT}
  4750.   D3DXIMAGE_FILEFORMAT = _D3DXIMAGE_FILEFORMAT;
  4751.   {$EXTERNALSYM D3DXIMAGE_FILEFORMAT}
  4752.   TD3DXImageFileFormat = _D3DXIMAGE_FILEFORMAT;
  4753.  
  4754.  
  4755. //----------------------------------------------------------------------------
  4756. // LPD3DXFILL2D and LPD3DXFILL3D:
  4757. // ------------------------------
  4758. // Function types used by the texture fill functions.
  4759. //
  4760. // Parameters:
  4761. //  pOut
  4762. //      Pointer to a vector which the function uses to return its result.
  4763. //      X,Y,Z,W will be mapped to R,G,B,A respectivly.
  4764. //  pTexCoord
  4765. //      Pointer to a vector containing the coordinates of the texel currently
  4766. //      being evaluated.  Textures and VolumeTexture texcoord components
  4767. //      range from 0 to 1. CubeTexture texcoord component range from -1 to 1.
  4768. //  pTexelSize
  4769. //      Pointer to a vector containing the dimensions of the current texel.
  4770. //  pData
  4771. //      Pointer to user data.
  4772. //
  4773. //----------------------------------------------------------------------------
  4774.  
  4775. type
  4776.   //typedef VOID (WINAPI *LPD3DXFILL2D)(D3DXVECTOR4 *pOut,
  4777.   //    CONST D3DXVECTOR2 *pTexCoord, CONST D3DXVECTOR2 *pTexelSize, LPVOID pData);
  4778.   TD3DXFill2D = procedure (out pOut: TD3DXVector4; const pTexCoord, pTexelSize: TD3DXVector2; var pData);
  4779.   {$NODEFINE TD3DXFill2D}
  4780.   {$HPPEMIT 'typedef LPD3DXFILL2D TD3DXFill2D;'}
  4781.  
  4782.   //typedef VOID (WINAPI *LPD3DXFILL3D)(D3DXVECTOR4 *pOut,
  4783.   //    CONST D3DXVECTOR3 *pTexCoord, CONST D3DXVECTOR3 *pTexelSize, LPVOID pData);
  4784.   TD3DXFill3D = procedure (out pOut: TD3DXVector4; const pTexCoord, pTexelSize: TD3DXVector3; var pData);
  4785.   {$NODEFINE TD3DXFill3D}
  4786.   {$HPPEMIT 'typedef LPD3DXFILL3D TD3DXFill3D;'}
  4787.  
  4788.  
  4789.  
  4790. //----------------------------------------------------------------------------
  4791. // D3DXIMAGE_INFO:
  4792. // ---------------
  4793. // This structure is used to return a rough description of what the
  4794. // the original contents of an image file looked like.
  4795. //
  4796. //  Width
  4797. //      Width of original image in pixels
  4798. //  Height
  4799. //      Height of original image in pixels
  4800. //  Depth
  4801. //      Depth of original image in pixels
  4802. //  MipLevels
  4803. //      Number of mip levels in original image
  4804. //  Format
  4805. //      D3D format which most closely describes the data in original image
  4806. //  ResourceType
  4807. //      D3DRESOURCETYPE representing the type of texture stored in the file.
  4808. //      D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE.
  4809. //  ImageFileFormat
  4810. //      D3DXIMAGE_FILEFORMAT representing the format of the image file.
  4811. //
  4812. //----------------------------------------------------------------------------
  4813.  
  4814. type
  4815.   PD3DXImageInfo = ^TD3DXImageInfo;
  4816.   _D3DXIMAGE_INFO = packed record
  4817.     Width:      LongWord;
  4818.     Height:     LongWord;
  4819.     Depth:      LongWord;
  4820.     MipLevels:  LongWord;
  4821.     Format:     TD3DFormat;
  4822.     ResourceType: TD3DResourceType;
  4823.     ImageFileFormat: TD3DXImageFileFormat;
  4824.   end;
  4825.   {$EXTERNALSYM _D3DXIMAGE_INFO}
  4826.   D3DXIMAGE_INFO = _D3DXIMAGE_INFO;
  4827.   {$EXTERNALSYM D3DXIMAGE_INFO}
  4828.   TD3DXImageInfo = _D3DXIMAGE_INFO;
  4829.  
  4830.  
  4831. //////////////////////////////////////////////////////////////////////////////
  4832. // Image File APIs ///////////////////////////////////////////////////////////
  4833. //////////////////////////////////////////////////////////////////////////////
  4834.  
  4835. //----------------------------------------------------------------------------
  4836. // GetImageInfoFromFile/Resource:
  4837. // ------------------------------
  4838. // Fills in a D3DXIMAGE_INFO struct with information about an image file.
  4839. //
  4840. // Parameters:
  4841. //  pSrcFile
  4842. //      File name of the source image.
  4843. //  pSrcModule
  4844. //      Module where resource is located, or NULL for module associated
  4845. //      with image the os used to create the current process.
  4846. //  pSrcResource
  4847. //      Resource name
  4848. //  pSrcData
  4849. //      Pointer to file in memory.
  4850. //  SrcDataSize
  4851. //      Size in bytes of file in memory.
  4852. //  pSrcInfo
  4853. //      Pointer to a D3DXIMAGE_INFO structure to be filled in with the
  4854. //      description of the data in the source image file.
  4855. //
  4856. //----------------------------------------------------------------------------
  4857.  
  4858. function D3DXGetImageInfoFromFileA(
  4859.   pSrcFile: PAnsiChar;
  4860.   out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXGetImageInfoFromFileA';
  4861. {$EXTERNALSYM D3DXGetImageInfoFromFileA}
  4862.  
  4863. function D3DXGetImageInfoFromFileW(
  4864.   pSrcFile: PWideChar;
  4865.   out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXGetImageInfoFromFileW';
  4866. {$EXTERNALSYM D3DXGetImageInfoFromFileW}
  4867.  
  4868. function D3DXGetImageInfoFromFile(
  4869.   pSrcFile: PChar;
  4870.   out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXGetImageInfoFromFileA';
  4871. {$EXTERNALSYM D3DXGetImageInfoFromFile}
  4872.  
  4873.  
  4874. function D3DXGetImageInfoFromResourceA(
  4875.   hSrcModule: HModule;
  4876.   pSrcResource: PAnsiChar;
  4877.   out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXGetImageInfoFromResourceA';
  4878. {$EXTERNALSYM D3DXGetImageInfoFromResourceA}
  4879.  
  4880. function D3DXGetImageInfoFromResourceW(
  4881.   hSrcModule: HModule;
  4882.   pSrcResource: PWideChar;
  4883.   out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXGetImageInfoFromResourceW';
  4884. {$EXTERNALSYM D3DXGetImageInfoFromResourceW}
  4885.  
  4886. function D3DXGetImageInfoFromResource(
  4887.   hSrcModule: HModule;
  4888.   pSrcResource: PChar;
  4889.   out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXGetImageInfoFromResourceA';
  4890. {$EXTERNALSYM D3DXGetImageInfoFromResource}
  4891.  
  4892.  
  4893. function D3DXGetImageInfoFromFileInMemory(
  4894.   const pSrcData;
  4895.   SrcDataSize: LongWord;
  4896.   out pSrcInfo: TD3DXImageInfo): HResult; stdcall; external d3dx9texDLL;
  4897. {$EXTERNALSYM D3DXGetImageInfoFromFileInMemory}
  4898.  
  4899.  
  4900. //////////////////////////////////////////////////////////////////////////////
  4901. // Load/Save Surface APIs ////////////////////////////////////////////////////
  4902. //////////////////////////////////////////////////////////////////////////////
  4903.  
  4904.  
  4905. //----------------------------------------------------------------------------
  4906. // D3DXLoadSurfaceFromFile/Resource:
  4907. // ---------------------------------
  4908. // Load surface from a file or resource
  4909. //
  4910. // Parameters:
  4911. //  pDestSurface
  4912. //      Destination surface, which will receive the image.
  4913. //  pDestPalette
  4914. //      Destination palette of 256 colors, or NULL
  4915. //  pDestRect
  4916. //      Destination rectangle, or NULL for entire surface
  4917. //  pSrcFile
  4918. //      File name of the source image.
  4919. //  pSrcModule
  4920. //      Module where resource is located, or NULL for module associated
  4921. //      with image the os used to create the current process.
  4922. //  pSrcResource
  4923. //      Resource name
  4924. //  pSrcData
  4925. //      Pointer to file in memory.
  4926. //  SrcDataSize
  4927. //      Size in bytes of file in memory.
  4928. //  pSrcRect
  4929. //      Source rectangle, or NULL for entire image
  4930. //  Filter
  4931. //      D3DX_FILTER flags controlling how the image is filtered.
  4932. //      Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  4933. //  ColorKey
  4934. //      Color to replace with transparent black, or 0 to disable colorkey.
  4935. //      This is always a 32-bit ARGB color, independent of the source image
  4936. //      format.  Alpha is significant, and should usually be set to FF for
  4937. //      opaque colorkeys.  (ex. Opaque black == 0xff000000)
  4938. //  pSrcInfo
  4939. //      Pointer to a D3DXIMAGE_INFO structure to be filled in with the
  4940. //      description of the data in the source image file, or NULL.
  4941. //
  4942. //----------------------------------------------------------------------------
  4943. function D3DXLoadSurfaceFromFileA(
  4944.   pDestSurface: IDirect3DSurface9;
  4945.   pDestPalette: PPaletteEntry;
  4946.   pDestRect: PRect;
  4947.   pSrcFile: PAnsiChar;
  4948.   pSrcRect: PRect;
  4949.   Filter: DWord;
  4950.   ColorKey: TD3DColor;
  4951.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXLoadSurfaceFromFileA';
  4952. {$EXTERNALSYM D3DXLoadSurfaceFromFileA}
  4953.  
  4954. function D3DXLoadSurfaceFromFileW(
  4955.   pDestSurface: IDirect3DSurface9;
  4956.   pDestPalette: PPaletteEntry;
  4957.   pDestRect: PRect;
  4958.   pSrcFile: PWideChar;
  4959.   pSrcRect: PRect;
  4960.   Filter: DWord;
  4961.   ColorKey: TD3DColor;
  4962.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXLoadSurfaceFromFileW';
  4963. {$EXTERNALSYM D3DXLoadSurfaceFromFileW}
  4964.  
  4965. function D3DXLoadSurfaceFromFile(
  4966.   pDestSurface: IDirect3DSurface9;
  4967.   pDestPalette: PPaletteEntry;
  4968.   pDestRect: PRect;
  4969.   pSrcFile: PChar;
  4970.   pSrcRect: PRect;
  4971.   Filter: DWord;
  4972.   ColorKey: TD3DColor;
  4973.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXLoadSurfaceFromFileA';
  4974. {$EXTERNALSYM D3DXLoadSurfaceFromFile}
  4975.  
  4976.  
  4977.  
  4978. function D3DXLoadSurfaceFromResourceA(
  4979.   pDestSurface: IDirect3DSurface9;
  4980.   pDestPalette: PPaletteEntry;
  4981.   pDestRect: PRect;
  4982.   hSrcModule: HModule;
  4983.   pSrcResource: PAnsiChar;
  4984.   pSrcRect: PRect;
  4985.   Filter: DWord;
  4986.   ColorKey: TD3DColor;
  4987.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXLoadSurfaceFromResourceA';
  4988. {$EXTERNALSYM D3DXLoadSurfaceFromResourceA}
  4989.  
  4990. function D3DXLoadSurfaceFromResourceW(
  4991.   pDestSurface: IDirect3DSurface9;
  4992.   pDestPalette: PPaletteEntry;
  4993.   pDestRect: PRect;
  4994.   hSrcModule: HModule;
  4995.   pSrcResource: PWideChar;
  4996.   pSrcRect: PRect;
  4997.   Filter: DWord;
  4998.   ColorKey: TD3DColor;
  4999.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXLoadSurfaceFromResourceW';
  5000. {$EXTERNALSYM D3DXLoadSurfaceFromResourceW}
  5001.  
  5002. function D3DXLoadSurfaceFromResource(
  5003.   pDestSurface: IDirect3DSurface9;
  5004.   pDestPalette: PPaletteEntry;
  5005.   pDestRect: PRect;
  5006.   hSrcModule: HModule;
  5007.   pSrcResource: PChar;
  5008.   pSrcRect: PRect;
  5009.   Filter: DWord;
  5010.   ColorKey: TD3DColor;
  5011.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXLoadSurfaceFromResourceA';
  5012. {$EXTERNALSYM D3DXLoadSurfaceFromResource}
  5013.  
  5014.  
  5015.  
  5016. function D3DXLoadSurfaceFromFileInMemory(
  5017.   pDestSurface: IDirect3DSurface9;
  5018.   pDestPalette: PPaletteEntry;
  5019.   pDestRect: PRect;
  5020.   const pSrcData;
  5021.   SrcDataSize: LongWord;
  5022.   pSrcRect: PRect;
  5023.   Filter: DWord;
  5024.   ColorKey: TD3DColor;
  5025.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx9texDLL;
  5026. {$EXTERNALSYM D3DXLoadSurfaceFromFileInMemory}
  5027.  
  5028.  
  5029.  
  5030. //----------------------------------------------------------------------------
  5031. // D3DXLoadSurfaceFromSurface:
  5032. // ---------------------------
  5033. // Load surface from another surface (with color conversion)
  5034. //
  5035. // Parameters:
  5036. //  pDestSurface
  5037. //      Destination surface, which will receive the image.
  5038. //  pDestPalette
  5039. //      Destination palette of 256 colors, or NULL
  5040. //  pDestRect
  5041. //      Destination rectangle, or NULL for entire surface
  5042. //  pSrcSurface
  5043. //      Source surface
  5044. //  pSrcPalette
  5045. //      Source palette of 256 colors, or NULL
  5046. //  pSrcRect
  5047. //      Source rectangle, or NULL for entire surface
  5048. //  Filter
  5049. //      D3DX_FILTER flags controlling how the image is filtered.
  5050. //      Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  5051. //  ColorKey
  5052. //      Color to replace with transparent black, or 0 to disable colorkey.
  5053. //      This is always a 32-bit ARGB color, independent of the source image
  5054. //      format.  Alpha is significant, and should usually be set to FF for
  5055. //      opaque colorkeys.  (ex. Opaque black == 0xff000000)
  5056. //
  5057. //----------------------------------------------------------------------------
  5058.  
  5059. function D3DXLoadSurfaceFromSurface(
  5060.   pDestSurface: IDirect3DSurface9;
  5061.   pDestPalette: PPaletteEntry;
  5062.   pDestRect: PRect;
  5063.   pSrcSurface: IDirect3DSurface9;
  5064.   pSrcPalette: PPaletteEntry;
  5065.   pSrcRect: PRect;
  5066.   Filter: DWord;
  5067.   ColorKey: TD3DColor): HResult; stdcall; external d3dx9texDLL;
  5068. {$EXTERNALSYM D3DXLoadSurfaceFromSurface}
  5069.  
  5070.  
  5071.  
  5072. //----------------------------------------------------------------------------
  5073. // D3DXLoadSurfaceFromMemory:
  5074. // ---------------------------
  5075. // Load surface from memory.
  5076. //
  5077. // Parameters:
  5078. //  pDestSurface
  5079. //      Destination surface, which will receive the image.
  5080. //  pDestPalette
  5081. //      Destination palette of 256 colors, or NULL
  5082. //  pDestRect
  5083. //      Destination rectangle, or NULL for entire surface
  5084. //  pSrcMemory
  5085. //      Pointer to the top-left corner of the source image in memory
  5086. //  SrcFormat
  5087. //      Pixel format of the source image.
  5088. //  SrcPitch
  5089. //      Pitch of source image, in bytes.  For DXT formats, this number
  5090. //      should represent the width of one row of cells, in bytes.
  5091. //  pSrcPalette
  5092. //      Source palette of 256 colors, or NULL
  5093. //  pSrcRect
  5094. //      Source rectangle.
  5095. //  Filter
  5096. //      D3DX_FILTER flags controlling how the image is filtered.
  5097. //      Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  5098. //  ColorKey
  5099. //      Color to replace with transparent black, or 0 to disable colorkey.
  5100. //      This is always a 32-bit ARGB color, independent of the source image
  5101. //      format.  Alpha is significant, and should usually be set to FF for
  5102. //      opaque colorkeys.  (ex. Opaque black == 0xff000000)
  5103. //
  5104. //----------------------------------------------------------------------------
  5105.  
  5106. function D3DXLoadSurfaceFromMemory(
  5107.   pDestSurface: IDirect3DSurface9;
  5108.   pDestPalette: PPaletteEntry;
  5109.   pDestRect: PRect;
  5110.   const pSrcMemory;
  5111.   SrcFormat: TD3DFormat;
  5112.   SrcPitch: LongWord;
  5113.   pSrcPalette: PPaletteEntry;
  5114.   pSrcRect: PRect;
  5115.   Filter: DWord;
  5116.   ColorKey: TD3DColor): HResult; stdcall; external d3dx9texDLL;
  5117. {$EXTERNALSYM D3DXLoadSurfaceFromMemory}
  5118.  
  5119.  
  5120.  
  5121. //----------------------------------------------------------------------------
  5122. // D3DXSaveSurfaceToFile:
  5123. // ----------------------
  5124. // Save a surface to a image file.
  5125. //
  5126. // Parameters:
  5127. //  pDestFile
  5128. //      File name of the destination file
  5129. //  DestFormat
  5130. //      D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
  5131. //  pSrcSurface
  5132. //      Source surface, containing the image to be saved
  5133. //  pSrcPalette
  5134. //      Source palette of 256 colors, or NULL
  5135. //  pSrcRect
  5136. //      Source rectangle, or NULL for the entire image
  5137. //
  5138. //----------------------------------------------------------------------------
  5139.  
  5140. function D3DXSaveSurfaceToFileA(
  5141.   pDestFile: PAnsiChar;
  5142.   DestFormat: TD3DXImageFileFormat;
  5143.   pSrcSurface: IDirect3DSurface9;
  5144.   pSrcPalette: PPaletteEntry;
  5145.   pSrcRect: PRect): HResult; stdcall; external d3dx9texDLL name 'D3DXSaveSurfaceToFileA';
  5146. {$EXTERNALSYM D3DXSaveSurfaceToFileA}
  5147.  
  5148. function D3DXSaveSurfaceToFileW(
  5149.   pDestFile: PWideChar;
  5150.   DestFormat: TD3DXImageFileFormat;
  5151.   pSrcSurface: IDirect3DSurface9;
  5152.   pSrcPalette: PPaletteEntry;
  5153.   pSrcRect: PRect): HResult; stdcall; external d3dx9texDLL name 'D3DXSaveSurfaceToFileW';
  5154. {$EXTERNALSYM D3DXSaveSurfaceToFileW}
  5155.  
  5156. function D3DXSaveSurfaceToFile(
  5157.   pDestFile: PChar;
  5158.   DestFormat: TD3DXImageFileFormat;
  5159.   pSrcSurface: IDirect3DSurface9;
  5160.   pSrcPalette: PPaletteEntry;
  5161.   pSrcRect: PRect): HResult; stdcall; external d3dx9texDLL name 'D3DXSaveSurfaceToFileA';
  5162. {$EXTERNALSYM D3DXSaveSurfaceToFile}
  5163.  
  5164.  
  5165.  
  5166. //////////////////////////////////////////////////////////////////////////////
  5167. // Load/Save Volume APIs /////////////////////////////////////////////////////
  5168. //////////////////////////////////////////////////////////////////////////////
  5169.  
  5170.  
  5171. //----------------------------------------------------------------------------
  5172. // D3DXLoadVolumeFromFile/Resource:
  5173. // --------------------------------
  5174. // Load volume from a file or resource
  5175. //
  5176. // Parameters:
  5177. //  pDestVolume
  5178. //      Destination volume, which will receive the image.
  5179. //  pDestPalette
  5180. //      Destination palette of 256 colors, or NULL
  5181. //  pDestBox
  5182. //      Destination box, or NULL for entire volume
  5183. //  pSrcFile
  5184. //      File name of the source image.
  5185. //  pSrcModule
  5186. //      Module where resource is located, or NULL for module associated
  5187. //      with image the os used to create the current process.
  5188. //  pSrcResource
  5189. //      Resource name
  5190. //  pSrcData
  5191. //      Pointer to file in memory.
  5192. //  SrcDataSize
  5193. //      Size in bytes of file in memory.
  5194. //  pSrcBox
  5195. //      Source box, or NULL for entire image
  5196. //  Filter
  5197. //      D3DX_FILTER flags controlling how the image is filtered.
  5198. //      Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  5199. //  ColorKey
  5200. //      Color to replace with transparent black, or 0 to disable colorkey.
  5201. //      This is always a 32-bit ARGB color, independent of the source image
  5202. //      format.  Alpha is significant, and should usually be set to FF for
  5203. //      opaque colorkeys.  (ex. Opaque black == 0xff000000)
  5204. //  pSrcInfo
  5205. //      Pointer to a D3DXIMAGE_INFO structure to be filled in with the
  5206. //      description of the data in the source image file, or NULL.
  5207. //
  5208. //----------------------------------------------------------------------------
  5209.  
  5210. function D3DXLoadVolumeFromFileA(
  5211.   pDestVolume: IDirect3DVolume9;
  5212.   pDestPalette: PPaletteEntry;
  5213.   pDestBox: TD3DBox;
  5214.   pSrcFile: PAnsiChar;
  5215.   pSrcBox: TD3DBox;
  5216.   Filter: DWord;
  5217.   ColorKey: TD3DColor;
  5218.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXLoadVolumeFromFileA';
  5219. {$EXTERNALSYM D3DXLoadVolumeFromFileA}
  5220.  
  5221. function D3DXLoadVolumeFromFileW(
  5222.   pDestVolume: IDirect3DVolume9;
  5223.   pDestPalette: PPaletteEntry;
  5224.   pDestBox: TD3DBox;
  5225.   pSrcFile: PWideChar;
  5226.   pSrcBox: TD3DBox;
  5227.   Filter: DWord;
  5228.   ColorKey: TD3DColor;
  5229.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXLoadVolumeFromFileW';
  5230. {$EXTERNALSYM D3DXLoadVolumeFromFileW}
  5231.  
  5232. function D3DXLoadVolumeFromFile(
  5233.   pDestVolume: IDirect3DVolume9;
  5234.   pDestPalette: PPaletteEntry;
  5235.   pDestBox: TD3DBox;
  5236.   pSrcFile: PChar;
  5237.   pSrcBox: TD3DBox;
  5238.   Filter: DWord;
  5239.   ColorKey: TD3DColor;
  5240.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXLoadVolumeFromFileA';
  5241. {$EXTERNALSYM D3DXLoadVolumeFromFile}
  5242.  
  5243.  
  5244. function D3DXLoadVolumeFromResourceA(
  5245.   pDestVolume: IDirect3DVolume9;
  5246.   pDestPalette: PPaletteEntry;
  5247.   pDestBox: TD3DBox;
  5248.   hSrcModule: HModule;
  5249.   pSrcResource: PAnsiChar;
  5250.   pSrcBox: TD3DBox;
  5251.   Filter: DWord;
  5252.   ColorKey: TD3DColor;
  5253.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXLoadVolumeFromResourceA';
  5254. {$EXTERNALSYM D3DXLoadVolumeFromResourceA}
  5255.  
  5256. function D3DXLoadVolumeFromResourceW(
  5257.   pDestVolume: IDirect3DVolume9;
  5258.   pDestPalette: PPaletteEntry;
  5259.   pDestBox: TD3DBox;
  5260.   hSrcModule: HModule;
  5261.   pSrcResource: PWideChar;
  5262.   pSrcBox: TD3DBox;
  5263.   Filter: DWord;
  5264.   ColorKey: TD3DColor;
  5265.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXLoadVolumeFromResourceW';
  5266. {$EXTERNALSYM D3DXLoadVolumeFromResourceW}
  5267.  
  5268. function D3DXLoadVolumeFromResource(
  5269.   pDestVolume: IDirect3DVolume9;
  5270.   pDestPalette: PPaletteEntry;
  5271.   pDestBox: TD3DBox;
  5272.   hSrcModule: HModule;
  5273.   pSrcResource: PChar;
  5274.   pSrcBox: TD3DBox;
  5275.   Filter: DWord;
  5276.   ColorKey: TD3DColor;
  5277.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx9texDLL name 'D3DXLoadVolumeFromResourceA';
  5278. {$EXTERNALSYM D3DXLoadVolumeFromResource}
  5279.  
  5280.  
  5281. function D3DXLoadVolumeFromFileInMemory(
  5282.   pDestVolume: IDirect3DVolume9;
  5283.   pDestPalette: PPaletteEntry;
  5284.   pDestBox: TD3DBox;
  5285.   const pSrcData;
  5286.   SrcDataSize: LongWord;
  5287.   pSrcBox: TD3DBox;
  5288.   Filter: DWord;
  5289.   ColorKey: TD3DColor;
  5290.   pSrcInfo: PD3DXImageInfo): HResult; stdcall; external d3dx9texDLL;
  5291. {$EXTERNALSYM D3DXLoadVolumeFromFileInMemory}
  5292.  
  5293.  
  5294.  
  5295. //----------------------------------------------------------------------------
  5296. // D3DXLoadVolumeFromVolume:
  5297. // ---------------------------
  5298. // Load volume from another volume (with color conversion)
  5299. //
  5300. // Parameters:
  5301. //  pDestVolume
  5302. //      Destination volume, which will receive the image.
  5303. //  pDestPalette
  5304. //      Destination palette of 256 colors, or NULL
  5305. //  pDestBox
  5306. //      Destination box, or NULL for entire volume
  5307. //  pSrcVolume
  5308. //      Source volume
  5309. //  pSrcPalette
  5310. //      Source palette of 256 colors, or NULL
  5311. //  pSrcBox
  5312. //      Source box, or NULL for entire volume
  5313. //  Filter
  5314. //      D3DX_FILTER flags controlling how the image is filtered.
  5315. //      Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  5316. //  ColorKey
  5317. //      Color to replace with transparent black, or 0 to disable colorkey.
  5318. //      This is always a 32-bit ARGB color, independent of the source image
  5319. //      format.  Alpha is significant, and should usually be set to FF for
  5320. //      opaque colorkeys.  (ex. Opaque black == 0xff000000)
  5321. //
  5322. //----------------------------------------------------------------------------
  5323.  
  5324. function D3DXLoadVolumeFromVolume(
  5325.   pDestVolume: IDirect3DVolume9;
  5326.   pDestPalette: PPaletteEntry;
  5327.   pDestBox: TD3DBox;
  5328.   pSrcVolume: IDirect3DVolume9;
  5329.   pSrcPalette: PPaletteEntry;
  5330.   pSrcBox: TD3DBox;
  5331.   Filter: DWord;
  5332.   ColorKey: TD3DColor): HResult; stdcall; external d3dx9texDLL;
  5333. {$EXTERNALSYM D3DXLoadVolumeFromVolume}
  5334.  
  5335.  
  5336.  
  5337. //----------------------------------------------------------------------------
  5338. // D3DXLoadVolumeFromMemory:
  5339. // ---------------------------
  5340. // Load volume from memory.
  5341. //
  5342. // Parameters:
  5343. //  pDestVolume
  5344. //      Destination volume, which will receive the image.
  5345. //  pDestPalette
  5346. //      Destination palette of 256 colors, or NULL
  5347. //  pDestBox
  5348. //      Destination box, or NULL for entire volume
  5349. //  pSrcMemory
  5350. //      Pointer to the top-left corner of the source volume in memory
  5351. //  SrcFormat
  5352. //      Pixel format of the source volume.
  5353. //  SrcRowPitch
  5354. //      Pitch of source image, in bytes.  For DXT formats, this number
  5355. //      should represent the size of one row of cells, in bytes.
  5356. //  SrcSlicePitch
  5357. //      Pitch of source image, in bytes.  For DXT formats, this number
  5358. //      should represent the size of one slice of cells, in bytes.
  5359. //  pSrcPalette
  5360. //      Source palette of 256 colors, or NULL
  5361. //  pSrcBox
  5362. //      Source box.
  5363. //  Filter
  5364. //      D3DX_FILTER flags controlling how the image is filtered.
  5365. //      Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  5366. //  ColorKey
  5367. //      Color to replace with transparent black, or 0 to disable colorkey.
  5368. //      This is always a 32-bit ARGB color, independent of the source image
  5369. //      format.  Alpha is significant, and should usually be set to FF for
  5370. //      opaque colorkeys.  (ex. Opaque black == 0xff000000)
  5371. //
  5372. //----------------------------------------------------------------------------
  5373.  
  5374. function D3DXLoadVolumeFromMemory(
  5375.   pDestVolume: IDirect3DVolume9;
  5376.   pDestPalette: PPaletteEntry;
  5377.   pDestBox: TD3DBox;
  5378.   const pSrcMemory;
  5379.   SrcFormat: TD3DFormat;
  5380.   SrcRowPitch: LongWord;
  5381.   SrcSlicePitch: LongWord;
  5382.   pSrcPalette: PPaletteEntry;
  5383.   pSrcBox: TD3DBox;
  5384.   Filter: DWord;
  5385.   ColorKey: TD3DColor): HResult; stdcall; external d3dx9texDLL;
  5386. {$EXTERNALSYM D3DXLoadVolumeFromMemory}
  5387.  
  5388.  
  5389.  
  5390. //----------------------------------------------------------------------------
  5391. // D3DXSaveVolumeToFile:
  5392. // ---------------------
  5393. // Save a volume to a image file.
  5394. //
  5395. // Parameters:
  5396. //  pDestFile
  5397. //      File name of the destination file
  5398. //  DestFormat
  5399. //      D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
  5400. //  pSrcVolume
  5401. //      Source volume, containing the image to be saved
  5402. //  pSrcPalette
  5403. //      Source palette of 256 colors, or NULL
  5404. //  pSrcBox
  5405. //      Source box, or NULL for the entire volume
  5406. //
  5407. //----------------------------------------------------------------------------
  5408.  
  5409. function D3DXSaveVolumeToFileA( 
  5410.   pDestFile: PAnsiChar;
  5411.   DestFormat: TD3DXImageFileFormat;
  5412.   pSrcVolume: IDirect3DVolume9;
  5413.   pSrcPalette: PPaletteEntry;
  5414.   pSrcBox: TD3DBox): HResult; stdcall; external d3dx9texDLL name 'D3DXSaveVolumeToFileA';
  5415. {$EXTERNALSYM D3DXSaveVolumeToFileA}
  5416.  
  5417. function D3DXSaveVolumeToFileW( 
  5418.   pDestFile: PWideChar;
  5419.   DestFormat: TD3DXImageFileFormat;
  5420.   pSrcVolume: IDirect3DVolume9;
  5421.   pSrcPalette: PPaletteEntry;
  5422.   pSrcBox: TD3DBox): HResult; stdcall; external d3dx9texDLL name 'D3DXSaveVolumeToFileW';
  5423. {$EXTERNALSYM D3DXSaveVolumeToFileW}
  5424.  
  5425. function D3DXSaveVolumeToFile( 
  5426.   pDestFile: PChar;
  5427.   DestFormat: TD3DXImageFileFormat;
  5428.   pSrcVolume: IDirect3DVolume9;
  5429.   pSrcPalette: PPaletteEntry;
  5430.   pSrcBox: TD3DBox): HResult; stdcall; external d3dx9texDLL name 'D3DXSaveVolumeToFileA';
  5431. {$EXTERNALSYM D3DXSaveVolumeToFile}
  5432.  
  5433.  
  5434.  
  5435. //////////////////////////////////////////////////////////////////////////////
  5436. // Create/Save Texture APIs //////////////////////////////////////////////////
  5437. //////////////////////////////////////////////////////////////////////////////
  5438.  
  5439.  
  5440. //----------------------------------------------------------------------------
  5441. // D3DXCheckTextureRequirements:
  5442. // -----------------------------
  5443. // Checks texture creation parameters.  If parameters are invalid, this
  5444. // function returns corrected parameters.
  5445. //
  5446. // Parameters:
  5447. //
  5448. //  pDevice
  5449. //      The D3D device to be used
  5450. //  pWidth, pHeight, pDepth, pSize
  5451. //      Desired size in pixels, or NULL.  Returns corrected size.
  5452. //  pNumMipLevels
  5453. //      Number of desired mipmap levels, or NULL.  Returns corrected number.
  5454. //  Usage
  5455. //      Texture usage flags
  5456. //  pFormat
  5457. //      Desired pixel format, or NULL.  Returns corrected format.
  5458. //  Pool
  5459. //      Memory pool to be used to create texture
  5460. //
  5461. //----------------------------------------------------------------------------
  5462. function D3DXCheckTextureRequirements(
  5463.   pDevice: IDirect3DDevice9;
  5464.   pWidth: PLongWord;
  5465.   pHeight: PLongWord;
  5466.   pNumMipLevels: PLongWord;
  5467.   Usage: DWord;
  5468.   pFormat: PD3DFormat;
  5469.   Pool: TD3DPool): HResult; stdcall; external d3dx9texDLL;
  5470. {$EXTERNALSYM D3DXCheckTextureRequirements}
  5471.  
  5472. function D3DXCheckCubeTextureRequirements(
  5473.   pDevice: IDirect3DDevice9;
  5474.   pSize: PLongWord;
  5475.   pNumMipLevels: PLongWord;
  5476.   Usage: DWord;
  5477.   pFormat: PD3DFormat;
  5478.   Pool: TD3DPool): HResult; stdcall; external d3dx9texDLL;
  5479. {$EXTERNALSYM D3DXCheckCubeTextureRequirements}
  5480.  
  5481. function D3DXCheckVolumeTextureRequirements(
  5482.   pDevice: IDirect3DDevice9;
  5483.   pWidth: PLongWord;
  5484.   pHeight: PLongWord;
  5485.   pDepth: PLongWord;
  5486.   pNumMipLevels: PLongWord;
  5487.   Usage: DWord;
  5488.   pFormat: PD3DFormat;
  5489.   Pool: TD3DPool): HResult; stdcall; external d3dx9texDLL;
  5490. {$EXTERNALSYM D3DXCheckVolumeTextureRequirements}
  5491.  
  5492.  
  5493. //----------------------------------------------------------------------------
  5494. // D3DXCreateTexture:
  5495. // ------------------
  5496. // Create an empty texture
  5497. //
  5498. // Parameters:
  5499. //
  5500. //  pDevice
  5501. //      The D3D device with which the texture is going to be used.
  5502. //  Width, Height, Depth, Size
  5503. //      size in pixels. these must be non-zero
  5504. //  MipLevels
  5505. //      number of mip levels desired. if zero or D3DX_DEFAULT, a complete
  5506. //      mipmap chain will be created.
  5507. //  Usage
  5508. //      Texture usage flags
  5509. //  Format
  5510. //      Pixel format.
  5511. //  Pool
  5512. //      Memory pool to be used to create texture
  5513. //  ppTexture, ppCubeTexture, ppVolumeTexture
  5514. //      The texture object that will be created
  5515. //
  5516. //----------------------------------------------------------------------------
  5517.  
  5518. function D3DXCreateTexture(
  5519.   Device: IDirect3DDevice9;
  5520.   Width: LongWord;
  5521.   Height: LongWord;
  5522.   MipLevels: LongWord;
  5523.   Usage: DWord;
  5524.   Format: TD3DFormat;
  5525.   Pool: TD3DPool;
  5526.   out ppTexture: IDirect3DTexture9): HResult; stdcall; external d3dx9texDLL;
  5527. {$EXTERNALSYM D3DXCreateTexture}
  5528.  
  5529. function D3DXCreateCubeTexture(
  5530.   Device: IDirect3DDevice9;
  5531.   Size: LongWord;
  5532.   MipLevels: LongWord;
  5533.   Usage: DWord;
  5534.   Format: TD3DFormat;
  5535.   Pool: TD3DPool;
  5536.   out ppCubeTexture: IDirect3DCubeTexture9): HResult; stdcall; external d3dx9texDLL;
  5537. {$EXTERNALSYM D3DXCreateCubeTexture}
  5538.  
  5539. function D3DXCreateVolumeTexture(
  5540.   Device: IDirect3DDevice9;
  5541.   Width: LongWord;
  5542.   Height: LongWord;
  5543.   Depth: LongWord;
  5544.   MipLevels: LongWord;
  5545.   Usage: DWord;
  5546.   Format: TD3DFormat;
  5547.   Pool: TD3DPool;
  5548.   out ppVolumeTexture: IDirect3DVolumeTexture9): HResult; stdcall; external d3dx9texDLL;
  5549. {$EXTERNALSYM D3DXCreateVolumeTexture}
  5550.  
  5551.  
  5552.  
  5553. //----------------------------------------------------------------------------
  5554. // D3DXCreateTextureFromFile/Resource:
  5555. // -----------------------------------
  5556. // Create a texture object from a file or resource.
  5557. //
  5558. // Parameters:
  5559. //
  5560. //  pDevice
  5561. //      The D3D device with which the texture is going to be used.
  5562. //  pSrcFile
  5563. //      File name.
  5564. //  hSrcModule
  5565. //      Module handle. if NULL, current module will be used.
  5566. //  pSrcResource
  5567. //      Resource name in module
  5568. //  pvSrcData
  5569. //      Pointer to file in memory.
  5570. //  SrcDataSize
  5571. //      Size in bytes of file in memory.
  5572. //  Width, Height, Depth, Size
  5573. //      Size in pixels.  If zero or D3DX_DEFAULT, the size will be taken from 
  5574. //      the file and rounded up to a power of two.  If D3DX_DEFAULT_NONPOW2, 
  5575. //      the size will be not be rounded, if the device supports NONPOW2 textures.
  5576. //  MipLevels
  5577. //      Number of mip levels.  If zero or D3DX_DEFAULT, a complete mipmap
  5578. //      chain will be created.
  5579. //  Usage
  5580. //      Texture usage flags
  5581. //  Format
  5582. //      Desired pixel format.  If D3DFMT_UNKNOWN, the format will be
  5583. //      taken from the file.
  5584. //  Pool
  5585. //      Memory pool to be used to create texture
  5586. //  Filter
  5587. //      D3DX_FILTER flags controlling how the image is filtered.
  5588. //      Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE.
  5589. //  MipFilter
  5590. //      D3DX_FILTER flags controlling how each miplevel is filtered.
  5591. //      Or D3DX_DEFAULT for D3DX_FILTER_BOX,
  5592. //  ColorKey
  5593. //      Color to replace with transparent black, or 0 to disable colorkey.
  5594. //      This is always a 32-bit ARGB color, independent of the source image
  5595. //      format.  Alpha is significant, and should usually be set to FF for
  5596. //      opaque colorkeys.  (ex. Opaque black == 0xff000000)
  5597. //  pSrcInfo
  5598. //      Pointer to a D3DXIMAGE_INFO structure to be filled in with the
  5599. //      description of the data in the source image file, or NULL.
  5600. //  pPalette
  5601. //      256 color palette to be filled in, or NULL
  5602. //  ppTexture, ppCubeTexture, ppVolumeTexture
  5603. //      The texture object that will be created
  5604. //
  5605. //----------------------------------------------------------------------------
  5606.  
  5607.  
  5608. // FromFile
  5609.  
  5610. function D3DXCreateTextureFromFileA(
  5611.   Device: IDirect3DDevice9;
  5612.   pSrcFile: PAnsiChar;
  5613.   out ppTexture: IDirect3DTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateTextureFromFileA';
  5614. {$EXTERNALSYM D3DXCreateTextureFromFileA}
  5615.  
  5616. function D3DXCreateTextureFromFileW(
  5617.   Device: IDirect3DDevice9;
  5618.   pSrcFile: PWideChar;
  5619.   out ppTexture: IDirect3DTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateTextureFromFileW';
  5620. {$EXTERNALSYM D3DXCreateTextureFromFileW}
  5621.  
  5622. function D3DXCreateTextureFromFile(
  5623.   Device: IDirect3DDevice9;
  5624.   pSrcFile: PChar;
  5625.   out ppTexture: IDirect3DTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateTextureFromFileA';
  5626. {$EXTERNALSYM D3DXCreateTextureFromFile}
  5627.  
  5628.  
  5629. function D3DXCreateCubeTextureFromFileA(
  5630.   Device: IDirect3DDevice9;
  5631.   pSrcFile: PAnsiChar;
  5632.   out ppCubeTexture: IDirect3DCubeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateCubeTextureFromFileA';
  5633. {$EXTERNALSYM D3DXCreateCubeTextureFromFileA}
  5634.  
  5635. function D3DXCreateCubeTextureFromFileW(
  5636.   Device: IDirect3DDevice9;
  5637.   pSrcFile: PWideChar;
  5638.   out ppCubeTexture: IDirect3DCubeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateCubeTextureFromFileW';
  5639. {$EXTERNALSYM D3DXCreateCubeTextureFromFileW}
  5640.  
  5641. function D3DXCreateCubeTextureFromFile(
  5642.   Device: IDirect3DDevice9;
  5643.   pSrcFile: PChar;
  5644.   out ppCubeTexture: IDirect3DCubeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateCubeTextureFromFileA';
  5645. {$EXTERNALSYM D3DXCreateCubeTextureFromFile}
  5646.  
  5647.  
  5648. function D3DXCreateVolumeTextureFromFileA(
  5649.   Device: IDirect3DDevice9;
  5650.   pSrcFile: PAnsiChar;
  5651.   out ppVolumeTexture: IDirect3DVolumeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateVolumeTextureFromFileA';
  5652. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileA}
  5653.  
  5654. function D3DXCreateVolumeTextureFromFileW(
  5655.   Device: IDirect3DDevice9;
  5656.   pSrcFile: PWideChar;
  5657.   out ppVolumeTexture: IDirect3DVolumeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateVolumeTextureFromFileW';
  5658. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileW}
  5659.  
  5660. function D3DXCreateVolumeTextureFromFile(
  5661.   Device: IDirect3DDevice9;
  5662.   pSrcFile: PChar;
  5663.   out ppVolumeTexture: IDirect3DVolumeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateVolumeTextureFromFileA';
  5664. {$EXTERNALSYM D3DXCreateVolumeTextureFromFile}
  5665.  
  5666.  
  5667. // FromResource
  5668.  
  5669. function D3DXCreateTextureFromResourceA(
  5670.   Device: IDirect3DDevice9;
  5671.   hSrcModule: HModule;
  5672.   pSrcResource: PAnsiChar;
  5673.   out ppTexture: IDirect3DTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateTextureFromResourceA';
  5674. {$EXTERNALSYM D3DXCreateTextureFromResourceA}
  5675.  
  5676. function D3DXCreateTextureFromResourceW(
  5677.   Device: IDirect3DDevice9;
  5678.   hSrcModule: HModule;
  5679.   pSrcResource: PWideChar;
  5680.   out ppTexture: IDirect3DTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateTextureFromResourceW';
  5681. {$EXTERNALSYM D3DXCreateTextureFromResourceW}
  5682.  
  5683. function D3DXCreateTextureFromResource(
  5684.   Device: IDirect3DDevice9;
  5685.   hSrcModule: HModule;
  5686.   pSrcResource: PChar;
  5687.   out ppTexture: IDirect3DTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateTextureFromResourceA';
  5688. {$EXTERNALSYM D3DXCreateTextureFromResource}
  5689.  
  5690.  
  5691. function D3DXCreateCubeTextureFromResourceA(
  5692.   Device: IDirect3DDevice9;
  5693.   hSrcModule: HModule;
  5694.   pSrcResource: PAnsiChar;
  5695.   out ppCubeTexture: IDirect3DCubeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateCubeTextureFromResourceA';
  5696. {$EXTERNALSYM D3DXCreateCubeTextureFromResourceA}
  5697.  
  5698. function D3DXCreateCubeTextureFromResourceW(
  5699.   Device: IDirect3DDevice9;
  5700.   hSrcModule: HModule;
  5701.   pSrcResource: PWideChar;
  5702.   out ppCubeTexture: IDirect3DCubeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateCubeTextureFromResourceW';
  5703. {$EXTERNALSYM D3DXCreateCubeTextureFromResourceW}
  5704.  
  5705. function D3DXCreateCubeTextureFromResource(
  5706.   Device: IDirect3DDevice9;
  5707.   hSrcModule: HModule;
  5708.   pSrcResource: PChar;
  5709.   out ppCubeTexture: IDirect3DCubeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateCubeTextureFromResourceA';
  5710. {$EXTERNALSYM D3DXCreateCubeTextureFromResource}
  5711.  
  5712.  
  5713. function D3DXCreateVolumeTextureFromResourceA(
  5714.   Device: IDirect3DDevice9;
  5715.   hSrcModule: HModule;
  5716.   pSrcResource: PAnsiChar;
  5717.   out ppVolumeTexture: IDirect3DVolumeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateVolumeTextureFromResourceA';
  5718. {$EXTERNALSYM D3DXCreateVolumeTextureFromResourceA}
  5719.  
  5720. function D3DXCreateVolumeTextureFromResourceW(
  5721.   Device: IDirect3DDevice9;
  5722.   hSrcModule: HModule;
  5723.   pSrcResource: PWideChar;
  5724.   out ppVolumeTexture: IDirect3DVolumeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateVolumeTextureFromResourceW';
  5725. {$EXTERNALSYM D3DXCreateVolumeTextureFromResourceW}
  5726.  
  5727. function D3DXCreateVolumeTextureFromResource(
  5728.   Device: IDirect3DDevice9;
  5729.   hSrcModule: HModule;
  5730.   pSrcResource: PChar;
  5731.   out ppVolumeTexture: IDirect3DVolumeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateVolumeTextureFromResourceA';
  5732. {$EXTERNALSYM D3DXCreateVolumeTextureFromResource}
  5733.  
  5734.  
  5735. // FromFileEx
  5736.  
  5737. function D3DXCreateTextureFromFileExA(
  5738.   Device: IDirect3DDevice9;
  5739.   pSrcFile: PAnsiChar;
  5740.   Width: LongWord;
  5741.   Height: LongWord;
  5742.   MipLevels: LongWord;
  5743.   Usage: DWord;
  5744.   Format: TD3DFormat;
  5745.   Pool: TD3DPool;
  5746.   Filter: DWord;
  5747.   MipFilter: DWord;
  5748.   ColorKey: TD3DColor;
  5749.   pSrcInfo: PD3DXImageInfo;
  5750.   pPalette: PPaletteEntry;
  5751.   out ppTexture: IDirect3DTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateTextureFromFileExA';
  5752. {$EXTERNALSYM D3DXCreateTextureFromFileExA}
  5753.  
  5754. function D3DXCreateTextureFromFileExW(
  5755.   Device: IDirect3DDevice9;
  5756.   pSrcFile: PWideChar;
  5757.   Width: LongWord;
  5758.   Height: LongWord;
  5759.   MipLevels: LongWord;
  5760.   Usage: DWord;
  5761.   Format: TD3DFormat;
  5762.   Pool: TD3DPool;
  5763.   Filter: DWord;
  5764.   MipFilter: DWord;
  5765.   ColorKey: TD3DColor;
  5766.   pSrcInfo: PD3DXImageInfo;
  5767.   pPalette: PPaletteEntry;
  5768.   out ppTexture: IDirect3DTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateTextureFromFileExW';
  5769. {$EXTERNALSYM D3DXCreateTextureFromFileExW}
  5770.  
  5771. function D3DXCreateTextureFromFileEx(
  5772.   Device: IDirect3DDevice9;
  5773.   pSrcFile: PChar;
  5774.   Width: LongWord;
  5775.   Height: LongWord;
  5776.   MipLevels: LongWord;
  5777.   Usage: DWord;
  5778.   Format: TD3DFormat;
  5779.   Pool: TD3DPool;
  5780.   Filter: DWord;
  5781.   MipFilter: DWord;
  5782.   ColorKey: TD3DColor;
  5783.   pSrcInfo: PD3DXImageInfo;
  5784.   pPalette: PPaletteEntry;
  5785.   out ppTexture: IDirect3DTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateTextureFromFileExA';
  5786. {$EXTERNALSYM D3DXCreateTextureFromFileEx}
  5787.  
  5788.  
  5789. function D3DXCreateCubeTextureFromFileExA(
  5790.   Device: IDirect3DDevice9;
  5791.   pSrcFile: PAnsiChar;
  5792.   Size: LongWord;
  5793.   MipLevels: LongWord;
  5794.   Usage: DWord;
  5795.   Format: TD3DFormat;
  5796.   Pool: TD3DPool;
  5797.   Filter: DWord;
  5798.   MipFilter: DWord;
  5799.   ColorKey: TD3DColor;
  5800.   pSrcInfo: PD3DXImageInfo;
  5801.   pPalette: PPaletteEntry;
  5802.   out ppCubeTexture: IDirect3DCubeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateCubeTextureFromFileExA';
  5803. {$EXTERNALSYM D3DXCreateCubeTextureFromFileExA}
  5804.  
  5805. function D3DXCreateCubeTextureFromFileExW(
  5806.   Device: IDirect3DDevice9;
  5807.   pSrcFile: PWideChar;
  5808.   Size: LongWord;
  5809.   MipLevels: LongWord;
  5810.   Usage: DWord;
  5811.   Format: TD3DFormat;
  5812.   Pool: TD3DPool;
  5813.   Filter: DWord;
  5814.   MipFilter: DWord;
  5815.   ColorKey: TD3DColor;
  5816.   pSrcInfo: PD3DXImageInfo;
  5817.   pPalette: PPaletteEntry;
  5818.   out ppCubeTexture: IDirect3DCubeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateCubeTextureFromFileExW';
  5819. {$EXTERNALSYM D3DXCreateCubeTextureFromFileExW}
  5820.  
  5821. function D3DXCreateCubeTextureFromFileEx(
  5822.   Device: IDirect3DDevice9;
  5823.   pSrcFile: PChar;
  5824.   Size: LongWord;
  5825.   MipLevels: LongWord;
  5826.   Usage: DWord;
  5827.   Format: TD3DFormat;
  5828.   Pool: TD3DPool;
  5829.   Filter: DWord;
  5830.   MipFilter: DWord;
  5831.   ColorKey: TD3DColor;
  5832.   pSrcInfo: PD3DXImageInfo;
  5833.   pPalette: PPaletteEntry;
  5834.   out ppCubeTexture: IDirect3DCubeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateCubeTextureFromFileExA';
  5835. {$EXTERNALSYM D3DXCreateCubeTextureFromFileEx}
  5836.  
  5837.  
  5838. function D3DXCreateVolumeTextureFromFileExA(
  5839.   Device: IDirect3DDevice9;
  5840.   pSrcFile: PAnsiChar;
  5841.   Width: LongWord;
  5842.   Height: LongWord;
  5843.   Depth: LongWord;
  5844.   MipLevels: LongWord;
  5845.   Usage: DWord;
  5846.   Format: TD3DFormat;
  5847.   Pool: TD3DPool;
  5848.   Filter: DWord;
  5849.   MipFilter: DWord;
  5850.   ColorKey: TD3DColor;
  5851.   pSrcInfo: PD3DXImageInfo;
  5852.   pPalette: PPaletteEntry;
  5853.   out ppVolumeTexture: IDirect3DVolumeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateVolumeTextureFromFileExA';
  5854. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileExA}
  5855.  
  5856. function D3DXCreateVolumeTextureFromFileExW(
  5857.   Device: IDirect3DDevice9;
  5858.   pSrcFile: PWideChar;
  5859.   Width: LongWord;
  5860.   Height: LongWord;
  5861.   Depth: LongWord;
  5862.   MipLevels: LongWord;
  5863.   Usage: DWord;
  5864.   Format: TD3DFormat;
  5865.   Pool: TD3DPool;
  5866.   Filter: DWord;
  5867.   MipFilter: DWord;
  5868.   ColorKey: TD3DColor;
  5869.   pSrcInfo: PD3DXImageInfo;
  5870.   pPalette: PPaletteEntry;
  5871.   out ppVolumeTexture: IDirect3DVolumeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateVolumeTextureFromFileExW';
  5872. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileExW}
  5873.  
  5874. function D3DXCreateVolumeTextureFromFileEx(
  5875.   Device: IDirect3DDevice9;
  5876.   pSrcFile: PChar;
  5877.   Width: LongWord;
  5878.   Height: LongWord;
  5879.   Depth: LongWord;
  5880.   MipLevels: LongWord;
  5881.   Usage: DWord;
  5882.   Format: TD3DFormat;
  5883.   Pool: TD3DPool;
  5884.   Filter: DWord;
  5885.   MipFilter: DWord;
  5886.   ColorKey: TD3DColor;
  5887.   pSrcInfo: PD3DXImageInfo;
  5888.   pPalette: PPaletteEntry;
  5889.   out ppVolumeTexture: IDirect3DVolumeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateVolumeTextureFromFileExA';
  5890. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileEx}
  5891.  
  5892.  
  5893. // FromResourceEx
  5894.  
  5895. function D3DXCreateTextureFromResourceExA(
  5896.   Device: IDirect3DDevice9;
  5897.   hSrcModule: HModule;
  5898.   pSrcResource: PAnsiChar;
  5899.   Width: LongWord;
  5900.   Height: LongWord;
  5901.   MipLevels: LongWord;
  5902.   Usage: DWord;
  5903.   Format: TD3DFormat;
  5904.   Pool: TD3DPool;
  5905.   Filter: DWord;
  5906.   MipFilter: DWord;
  5907.   ColorKey: TD3DColor;
  5908.   pSrcInfo: PD3DXImageInfo;
  5909.   pPalette: PPaletteEntry;
  5910.   out ppTexture: IDirect3DTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateTextureFromResourceExA';
  5911. {$EXTERNALSYM D3DXCreateTextureFromResourceExA}
  5912.  
  5913. function D3DXCreateTextureFromResourceExW(
  5914.   Device: IDirect3DDevice9;
  5915.   hSrcModule: HModule;
  5916.   pSrcResource: PWideChar;
  5917.   Width: LongWord;
  5918.   Height: LongWord;
  5919.   MipLevels: LongWord;
  5920.   Usage: DWord;
  5921.   Format: TD3DFormat;
  5922.   Pool: TD3DPool;
  5923.   Filter: DWord;
  5924.   MipFilter: DWord;
  5925.   ColorKey: TD3DColor;
  5926.   pSrcInfo: PD3DXImageInfo;
  5927.   pPalette: PPaletteEntry;
  5928.   out ppTexture: IDirect3DTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateTextureFromResourceExW';
  5929. {$EXTERNALSYM D3DXCreateTextureFromResourceExW}
  5930.  
  5931. function D3DXCreateTextureFromResourceEx(
  5932.   Device: IDirect3DDevice9;
  5933.   hSrcModule: HModule;
  5934.   pSrcResource: PChar;
  5935.   Width: LongWord;
  5936.   Height: LongWord;
  5937.   MipLevels: LongWord;
  5938.   Usage: DWord;
  5939.   Format: TD3DFormat;
  5940.   Pool: TD3DPool;
  5941.   Filter: DWord;
  5942.   MipFilter: DWord;
  5943.   ColorKey: TD3DColor;
  5944.   pSrcInfo: PD3DXImageInfo;
  5945.   pPalette: PPaletteEntry;
  5946.   out ppTexture: IDirect3DTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateTextureFromResourceExA';
  5947. {$EXTERNALSYM D3DXCreateTextureFromResourceEx}
  5948.  
  5949.  
  5950. function D3DXCreateCubeTextureFromResourceExA(
  5951.   Device: IDirect3DDevice9;
  5952.   hSrcModule: HModule;
  5953.   pSrcResource: PAnsiChar;
  5954.   Size: LongWord;
  5955.   MipLevels: LongWord;
  5956.   Usage: DWord;
  5957.   Format: TD3DFormat;
  5958.   Pool: TD3DPool;
  5959.   Filter: DWord;
  5960.   MipFilter: DWord;
  5961.   ColorKey: TD3DColor;
  5962.   pSrcInfo: PD3DXImageInfo;
  5963.   pPalette: PPaletteEntry;
  5964.   out ppCubeTexture: IDirect3DCubeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateCubeTextureFromResourceExA';
  5965. {$EXTERNALSYM D3DXCreateCubeTextureFromResourceExA}
  5966.  
  5967. function D3DXCreateCubeTextureFromResourceExW(
  5968.   Device: IDirect3DDevice9;
  5969.   hSrcModule: HModule;
  5970.   pSrcResource: PWideChar;
  5971.   Size: LongWord;
  5972.   MipLevels: LongWord;
  5973.   Usage: DWord;
  5974.   Format: TD3DFormat;
  5975.   Pool: TD3DPool;
  5976.   Filter: DWord;
  5977.   MipFilter: DWord;
  5978.   ColorKey: TD3DColor;
  5979.   pSrcInfo: PD3DXImageInfo;
  5980.   pPalette: PPaletteEntry;
  5981.   out ppCubeTexture: IDirect3DCubeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateCubeTextureFromResourceExW';
  5982. {$EXTERNALSYM D3DXCreateCubeTextureFromResourceExW}
  5983.  
  5984. function D3DXCreateCubeTextureFromResourceEx(
  5985.   Device: IDirect3DDevice9;
  5986.   hSrcModule: HModule;
  5987.   pSrcResource: PChar;
  5988.   Size: LongWord;
  5989.   MipLevels: LongWord;
  5990.   Usage: DWord;
  5991.   Format: TD3DFormat;
  5992.   Pool: TD3DPool;
  5993.   Filter: DWord;
  5994.   MipFilter: DWord;
  5995.   ColorKey: TD3DColor;
  5996.   pSrcInfo: PD3DXImageInfo;
  5997.   pPalette: PPaletteEntry;
  5998.   out ppCubeTexture: IDirect3DCubeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateCubeTextureFromResourceExA';
  5999. {$EXTERNALSYM D3DXCreateCubeTextureFromResourceEx}
  6000.  
  6001.  
  6002. function D3DXCreateVolumeTextureFromResourceExA(
  6003.   Device: IDirect3DDevice9;
  6004.   hSrcModule: HModule;
  6005.   pSrcResource: PAnsiChar;
  6006.   Width: LongWord;
  6007.   Height: LongWord;
  6008.   Depth: LongWord;
  6009.   MipLevels: LongWord;
  6010.   Usage: DWord;
  6011.   Format: TD3DFormat;
  6012.   Pool: TD3DPool;
  6013.   Filter: DWord;
  6014.   MipFilter: DWord;
  6015.   ColorKey: TD3DColor;
  6016.   pSrcInfo: PD3DXImageInfo;
  6017.   pPalette: PPaletteEntry;
  6018.   out ppVolumeTexture: IDirect3DVolumeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateVolumeTextureFromResourceExA';
  6019. {$EXTERNALSYM D3DXCreateVolumeTextureFromResourceExA}
  6020.  
  6021. function D3DXCreateVolumeTextureFromResourceExW(
  6022.   Device: IDirect3DDevice9;
  6023.   hSrcModule: HModule;
  6024.   pSrcResource: PWideChar;
  6025.   Width: LongWord;
  6026.   Height: LongWord;
  6027.   Depth: LongWord;
  6028.   MipLevels: LongWord;
  6029.   Usage: DWord;
  6030.   Format: TD3DFormat;
  6031.   Pool: TD3DPool;
  6032.   Filter: DWord;
  6033.   MipFilter: DWord;
  6034.   ColorKey: TD3DColor;
  6035.   pSrcInfo: PD3DXImageInfo;
  6036.   pPalette: PPaletteEntry;
  6037.   out ppVolumeTexture: IDirect3DVolumeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateVolumeTextureFromResourceExW';
  6038. {$EXTERNALSYM D3DXCreateVolumeTextureFromResourceExW}
  6039.  
  6040. function D3DXCreateVolumeTextureFromResourceEx(
  6041.   Device: IDirect3DDevice9;
  6042.   hSrcModule: HModule;
  6043.   pSrcResource: PChar;
  6044.   Width: LongWord;
  6045.   Height: LongWord;
  6046.   Depth: LongWord;
  6047.   MipLevels: LongWord;
  6048.   Usage: DWord;
  6049.   Format: TD3DFormat;
  6050.   Pool: TD3DPool;
  6051.   Filter: DWord;
  6052.   MipFilter: DWord;
  6053.   ColorKey: TD3DColor;
  6054.   pSrcInfo: PD3DXImageInfo;
  6055.   pPalette: PPaletteEntry;
  6056.   out ppVolumeTexture: IDirect3DVolumeTexture9): HResult; stdcall; external d3dx9texDLL name 'D3DXCreateVolumeTextureFromResourceExA';
  6057. {$EXTERNALSYM D3DXCreateVolumeTextureFromResourceEx}
  6058.  
  6059.  
  6060. // FromFileInMemory
  6061.  
  6062. function D3DXCreateTextureFromFileInMemory(
  6063.   Device: IDirect3DDevice9;
  6064.   const pSrcData;
  6065.   SrcDataSize: LongWord;
  6066.   out ppTexture: IDirect3DTexture9): HResult; stdcall; external d3dx9texDLL;
  6067. {$EXTERNALSYM D3DXCreateTextureFromFileInMemory}
  6068.  
  6069. function D3DXCreateCubeTextureFromFileInMemory(
  6070.   Device: IDirect3DDevice9;
  6071.   const pSrcData;
  6072.   SrcDataSize: LongWord;
  6073.   out ppCubeTexture: IDirect3DCubeTexture9): HResult; stdcall; external d3dx9texDLL;
  6074. {$EXTERNALSYM D3DXCreateCubeTextureFromFileInMemory}
  6075.  
  6076. function D3DXCreateVolumeTextureFromFileInMemory(
  6077.   Device: IDirect3DDevice9;
  6078.   const pSrcData;
  6079.   SrcDataSize: LongWord;
  6080.   out ppVolumeTexture: IDirect3DVolumeTexture9): HResult; stdcall; external d3dx9texDLL;
  6081. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileInMemory}
  6082.  
  6083.  
  6084. // FromFileInMemoryEx
  6085.  
  6086. function D3DXCreateTextureFromFileInMemoryEx(
  6087.   Device: IDirect3DDevice9;
  6088.   const pSrcData;
  6089.   SrcDataSize: LongWord;
  6090.   Width: LongWord;
  6091.   Height: LongWord;
  6092.   MipLevels: LongWord;
  6093.   Usage: DWord;
  6094.   Format: TD3DFormat;
  6095.   Pool: TD3DPool;
  6096.   Filter: DWord;
  6097.   MipFilter: DWord;
  6098.   ColorKey: TD3DColor;
  6099.   pSrcInfo: PD3DXImageInfo;
  6100.   pPalette: PPaletteEntry;
  6101.   out ppTexture: IDirect3DTexture9): HResult; stdcall; external d3dx9texDLL;
  6102. {$EXTERNALSYM D3DXCreateTextureFromFileInMemoryEx}
  6103.  
  6104. function D3DXCreateCubeTextureFromFileInMemoryEx(
  6105.   Device: IDirect3DDevice9;
  6106.   const pSrcData;
  6107.   SrcDataSize: LongWord;
  6108.   Size: LongWord;
  6109.   MipLevels: LongWord;
  6110.   Usage: DWord;
  6111.   Format: TD3DFormat;
  6112.   Pool: TD3DPool;
  6113.   Filter: DWord;
  6114.   MipFilter: DWord;
  6115.   ColorKey: TD3DColor;
  6116.   pSrcInfo: PD3DXImageInfo;
  6117.   pPalette: PPaletteEntry;
  6118.   out ppCubeTexture: IDirect3DCubeTexture9): HResult; stdcall; external d3dx9texDLL;
  6119. {$EXTERNALSYM D3DXCreateCubeTextureFromFileInMemoryEx}
  6120.  
  6121. function D3DXCreateVolumeTextureFromFileInMemoryEx(
  6122.   Device: IDirect3DDevice9;
  6123.   const pSrcData;
  6124.   SrcDataSize: LongWord;
  6125.   Width: LongWord;
  6126.   Height: LongWord;
  6127.   Depth: LongWord;
  6128.   MipLevels: LongWord;
  6129.   Usage: DWord;
  6130.   Format: TD3DFormat;
  6131.   Pool: TD3DPool;
  6132.   Filter: DWord;
  6133.   MipFilter: DWord;
  6134.   ColorKey: TD3DColor;
  6135.   pSrcInfo: PD3DXImageInfo;
  6136.   pPalette: PPaletteEntry;
  6137.   out ppVolumeTexture: IDirect3DVolumeTexture9): HResult; stdcall; external d3dx9texDLL;
  6138. {$EXTERNALSYM D3DXCreateVolumeTextureFromFileInMemoryEx}
  6139.  
  6140.  
  6141.  
  6142. //----------------------------------------------------------------------------
  6143. // D3DXSaveTextureToFile:
  6144. // ----------------------
  6145. // Save a texture to a file.
  6146. //
  6147. // Parameters:
  6148. //  pDestFile
  6149. //      File name of the destination file
  6150. //  DestFormat
  6151. //      D3DXIMAGE_FILEFORMAT specifying file format to use when saving.
  6152. //  pSrcTexture
  6153. //      Source texture, containing the image to be saved
  6154. //  pSrcPalette
  6155. //      Source palette of 256 colors, or NULL
  6156. //
  6157. //----------------------------------------------------------------------------
  6158.  
  6159.  
  6160. function D3DXSaveTextureToFileA(
  6161.   pDestFile: PAnsiChar;
  6162.   DestFormat: TD3DXImageFileFormat;
  6163.   pSrcTexture: IDirect3DBaseTexture9;
  6164.   pSrcPalette: PPaletteEntry): HResult; stdcall; external d3dx9texDLL name 'D3DXSaveTextureToFileA';
  6165. {$EXTERNALSYM D3DXSaveTextureToFileA}
  6166.  
  6167. function D3DXSaveTextureToFileW(
  6168.   pDestFile: PWideChar;
  6169.   DestFormat: TD3DXImageFileFormat;
  6170.   pSrcTexture: IDirect3DBaseTexture9;
  6171.   pSrcPalette: PPaletteEntry): HResult; stdcall; external d3dx9texDLL name 'D3DXSaveTextureToFileW';
  6172. {$EXTERNALSYM D3DXSaveTextureToFileW}
  6173.  
  6174. function D3DXSaveTextureToFile(
  6175.   pDestFile: PChar;
  6176.   DestFormat: TD3DXImageFileFormat;
  6177.   pSrcTexture: IDirect3DBaseTexture9;
  6178.   pSrcPalette: PPaletteEntry): HResult; stdcall; external d3dx9texDLL name 'D3DXSaveTextureToFileA';
  6179. {$EXTERNALSYM D3DXSaveTextureToFile}
  6180.  
  6181.  
  6182.  
  6183.  
  6184. //////////////////////////////////////////////////////////////////////////////
  6185. // Misc Texture APIs /////////////////////////////////////////////////////////
  6186. //////////////////////////////////////////////////////////////////////////////
  6187.  
  6188. //----------------------------------------------------------------------------
  6189. // D3DXFilterTexture:
  6190. // ------------------
  6191. // Filters mipmaps levels of a texture.
  6192. //
  6193. // Parameters:
  6194. //  pBaseTexture
  6195. //      The texture object to be filtered
  6196. //  pPalette
  6197. //      256 color palette to be used, or NULL for non-palettized formats
  6198. //  SrcLevel
  6199. //      The level whose image is used to generate the subsequent levels.
  6200. //  Filter
  6201. //      D3DX_FILTER flags controlling how each miplevel is filtered.
  6202. //      Or D3DX_DEFAULT for D3DX_FILTER_BOX,
  6203. //
  6204. //-------------------------------------------------------------------------
  6205.  
  6206. function D3DXFilterTexture(
  6207.   pTexture: IDirect3DTexture9;
  6208.   pPalette: PPaletteEntry;
  6209.   SrcLevel: LongWord;
  6210.   Filter: DWord): HResult; stdcall; external d3dx9texDLL;
  6211. {$EXTERNALSYM D3DXFilterTexture}
  6212.  
  6213. // #define D3DXFilterCubeTexture D3DXFilterTexture
  6214. // In Pascal this mapped to DLL-exported "D3DXFilterTexture" function
  6215. function D3DXFilterCubeTexture(
  6216.   pTexture: IDirect3DCubeTexture9;
  6217.   pPalette: PPaletteEntry;
  6218.   SrcLevel: LongWord;
  6219.   Filter: DWord): HResult; stdcall; external d3dx9texDLL name 'D3DXFilterTexture';
  6220. {$EXTERNALSYM D3DXFilterCubeTexture}
  6221.  
  6222. // #define D3DXFilterVolumeTexture D3DXFilterTexture
  6223. // In Pascal this mapped to DLL-exported "D3DXFilterTexture" function
  6224. function D3DXFilterVolumeTexture(
  6225.   pTexture: IDirect3DVolumeTexture9;
  6226.   pPalette: PPaletteEntry;
  6227.   SrcLevel: LongWord;
  6228.   Filter: DWord): HResult; stdcall; external d3dx9texDLL name 'D3DXFilterTexture';
  6229. {$EXTERNALSYM D3DXFilterVolumeTexture}
  6230.  
  6231.  
  6232.  
  6233. //----------------------------------------------------------------------------
  6234. // D3DXFillTexture:
  6235. // ----------------
  6236. // Uses a user provided function to fill each texel of each mip level of a
  6237. // given texture.
  6238. //
  6239. // Paramters:
  6240. //  pTexture, pCubeTexture, pVolumeTexture
  6241. //      Pointer to the texture to be filled.
  6242. //  pFunction
  6243. //      Pointer to user provided evalutor function which will be used to
  6244. //      compute the value of each texel.
  6245. //  pData
  6246. //      Pointer to an arbitrary block of user defined data.  This pointer
  6247. //      will be passed to the function provided in pFunction
  6248. //-----------------------------------------------------------------------------
  6249.  
  6250. function D3DXFillTexture(
  6251.   pTexture: IDirect3DTexture9;
  6252.   pFunction: TD3DXFill2D;
  6253.   const pData): HResult; stdcall; external d3dx9texDLL;
  6254. {$EXTERNALSYM D3DXFillTexture}
  6255.  
  6256. function D3DXFillCubeTexture(
  6257.   pCubeTexture: IDirect3DCubeTexture9;
  6258.   pFunction: TD3DXFill2D;
  6259.   const pData): HResult; stdcall; external d3dx9texDLL;
  6260. {$EXTERNALSYM D3DXFillCubeTexture}
  6261.  
  6262. function D3DXFillVolumeTexture(
  6263.   pVolumeTexture: IDirect3DVolumeTexture9;
  6264.   pFunction: TD3DXFill3D;
  6265.   const pData): HResult; stdcall; external d3dx9texDLL;
  6266. {$EXTERNALSYM D3DXFillVolumeTexture}
  6267.  
  6268. //----------------------------------------------------------------------------
  6269. // D3DXFillTextureTX:
  6270. // ----------------
  6271. // Uses a TX Shader target to function to fill each texel of each mip level of a
  6272. // given texture. The TX Shader target should be a compiled function taking 2
  6273. // 2 paramters and returning a float4 color.
  6274. //
  6275. // Paramters:
  6276. //  pTexture, pCubeTexture, pVolumeTexture
  6277. //      Pointer to the texture to be filled.
  6278. //  pFunction:
  6279. //      Pointer to the compiled function returned by D3DX
  6280. //  pConstants
  6281. //      Constants used by program. Should be filled by user by parsing constant
  6282. //      Table information
  6283. //  Constants
  6284. //      Number of Constants
  6285. //-----------------------------------------------------------------------------
  6286.  
  6287. function D3DXFillTextureTX(
  6288.   pTexture: IDirect3DTexture9;
  6289.   pFunction: PDWORD;
  6290.   pConstants: PD3DXVector4;
  6291.   Constants: LongWord): HResult; stdcall; external d3dx9texDLL;
  6292. {$EXTERNALSYM D3DXFillTextureTX}
  6293.  
  6294.  
  6295. function D3DXFillCubeTextureTX(
  6296.   pCubeTexture: IDirect3DCubeTexture9;
  6297.   pFunction: PDWORD;
  6298.   pConstants: PD3DXVector4;
  6299.   Constants: LongWord): HResult; stdcall; external d3dx9texDLL;
  6300. {$EXTERNALSYM D3DXFillCubeTextureTX}
  6301.  
  6302.  
  6303. function D3DXFillVolumeTextureTX(
  6304.   pVolumeTexture: IDirect3DVolumeTexture9;
  6305.   pFunction: PDWORD;
  6306.   pConstants: PD3DXVector4;
  6307.   Constants: LongWord): HResult; stdcall; external d3dx9texDLL;
  6308. {$EXTERNALSYM D3DXFillVolumeTextureTX}
  6309.  
  6310.  
  6311. //----------------------------------------------------------------------------
  6312. // D3DXComputeNormalMap:
  6313. // ---------------------
  6314. // Converts a height map into a normal map.  The (x,y,z) components of each
  6315. // normal are mapped to the (r,g,b) channels of the output texture.
  6316. //
  6317. // Parameters
  6318. //  pTexture
  6319. //      Pointer to the destination texture
  6320. //  pSrcTexture
  6321. //      Pointer to the source heightmap texture
  6322. //  pSrcPalette
  6323. //      Source palette of 256 colors, or NULL
  6324. //  Flags
  6325. //      D3DX_NORMALMAP flags
  6326. //  Channel
  6327. //      D3DX_CHANNEL specifying source of height information
  6328. //  Amplitude
  6329. //      The constant value which the height information is multiplied by.
  6330. //---------------------------------------------------------------------------
  6331.  
  6332. function D3DXComputeNormalMap(
  6333.   pTexture: IDirect3DTexture9;
  6334.   pSrcTexture: IDirect3DTexture9;
  6335.   pSrcPalette: PPaletteEntry;
  6336.   Flags: DWord;
  6337.   Channel: DWord;
  6338.   Amplitude: Single): HResult; stdcall; external d3dx9texDLL;
  6339. {$EXTERNALSYM D3DXComputeNormalMap}
  6340.  
  6341.  
  6342.  
  6343.  
  6344.  
  6345. //////////////////////////////////////////////////////////////////////////////
  6346. //
  6347. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  6348. //
  6349. //  File:       d3dx9anim.h
  6350. //  Content:    D3DX mesh types and functions
  6351. //
  6352. //////////////////////////////////////////////////////////////////////////////
  6353.  
  6354. type
  6355. //----------------------------------------------------------------------------
  6356. // This enum defines the type of mesh data present in a MeshData structure
  6357. //----------------------------------------------------------------------------
  6358.   _D3DXMESHDATATYPE = (
  6359.   {$IFNDEF COMPILER6_UP}
  6360.     D3DXMESHTYPE_invalid_0,
  6361.     D3DXMESHTYPE_MESH      {= $001},     // normal ID3DXMesh data
  6362.     D3DXMESHTYPE_PMESH     {= $002},     // Progressive Mesh - ID3DXPMesh
  6363.     D3DXMESHTYPE_PATCHMESH {= $003}      // Patch MEsh - ID3DXPatchMesh
  6364.   {$ELSE}
  6365.     D3DXMESHTYPE_MESH      = $001,     // normal ID3DXMesh data
  6366.     D3DXMESHTYPE_PMESH     = $002,     // Progressive Mesh - ID3DXPMesh
  6367.     D3DXMESHTYPE_PATCHMESH = $003      // Patch MEsh - ID3DXPatchMesh
  6368.   {$ENDIF}
  6369.   );
  6370.   {$EXTERNALSYM _D3DXMESHDATATYPE}
  6371.   D3DXMESHDATATYPE = _D3DXMESHDATATYPE;
  6372.   {$EXTERNALSYM D3DXMESHDATATYPE}
  6373.   TD3DXMeshDataType = _D3DXMESHDATATYPE;
  6374.  
  6375. //----------------------------------------------------------------------------
  6376. // This struct encapsulates a the mesh data that can be present in a mesh
  6377. //   container.  The supported mesh types are pMesh, pPMesh, pPatchMesh
  6378. //   The valid way to access this is determined by the MeshType enum
  6379. //----------------------------------------------------------------------------
  6380.   PD3DXMeshData = ^TD3DXMeshData;
  6381.   _D3DXMESHDATA = packed record
  6382.     _Type: TD3DXMeshDataType;
  6383.  
  6384.     // current mesh data interface
  6385.     // *** Translator ***: Delphi doesn't allow interfaces in variant records
  6386.     // so I declare only one field that can be casted in code, for examples, as:
  6387.     // either  "mesh := ID3DXPatchMesh(pPatchMesh)"
  6388.     // or      "mesh := pPatchMesh as ID3DXPatchMesh"
  6389.     pMesh: IUnknown;
  6390. {   case Byte of // In Delphi use pMesh record item as defined above
  6391.       0: (pMesh:              ID3DXMesh);
  6392.       1: (pPMesh:             ID3DXPMesh);
  6393.       2: (pPatchMesh:         ID3DXPatchMesh); }
  6394.   end;
  6395.   {$EXTERNALSYM _D3DXMESHDATA}
  6396.   D3DXMESHDATA = _D3DXMESHDATA;
  6397.   {$EXTERNALSYM D3DXMESHDATA}
  6398.   TD3DXMeshData = _D3DXMESHDATA;
  6399.  
  6400. //----------------------------------------------------------------------------
  6401. // This struct encapsulates a mesh object in a transformation frame
  6402. // hierarchy. The app can derive from this structure to add other app specific
  6403. // data to this
  6404. //----------------------------------------------------------------------------
  6405.   PD3DXMeshContainer = ^TD3DXMeshContainer;
  6406.   _D3DXMESHCONTAINER = packed record
  6407.     Name:               PAnsiChar;
  6408.  
  6409.     MeshData:           TD3DXMeshData;
  6410.  
  6411.     pMaterials:         PD3DXMaterial;
  6412.     pEffects:           PD3DXEffectInstance;
  6413.     NumMaterials:       DWORD;
  6414.     pAdjacency:         PDWORD;
  6415.  
  6416.     pSkinInfo:          ID3DXSkinInfo;
  6417.  
  6418.     pNextMeshContainer: PD3DXMeshContainer;
  6419.   end;
  6420.   {$EXTERNALSYM _D3DXMESHCONTAINER}
  6421.   D3DXMESHCONTAINER = _D3DXMESHCONTAINER;
  6422.   {$EXTERNALSYM D3DXMESHCONTAINER}
  6423.   TD3DXMeshContainer = _D3DXMESHCONTAINER;
  6424.  
  6425. //----------------------------------------------------------------------------
  6426. // This struct is the encapsulates a transform frame in a transformation frame
  6427. // hierarchy. The app can derive from this structure to add other app specific
  6428. // data to this
  6429. //----------------------------------------------------------------------------
  6430.   PD3DXFrame = ^TD3DXFrame;
  6431.   _D3DXFRAME = packed record
  6432.     Name:               PAnsiChar;
  6433.     TransformationMatrix: TD3DXMatrix;
  6434.  
  6435.     pMeshContainer:     PD3DXMeshContainer;
  6436.  
  6437.     pFrameSibling:      PD3DXFrame;
  6438.     pFrameFirstChild:   PD3DXFrame;
  6439.   end;
  6440.   {$EXTERNALSYM _D3DXFRAME}
  6441.   D3DXFRAME = _D3DXFRAME;
  6442.   {$EXTERNALSYM D3DXFRAME}
  6443.   TD3DXFrame = _D3DXFRAME;
  6444.  
  6445.  
  6446. //----------------------------------------------------------------------------
  6447. // This interface is implemented by the application to allocate/free frame and
  6448. // mesh container objects. Methods on this are called during loading and
  6449. // destroying frame hierarchies
  6450. //----------------------------------------------------------------------------
  6451. //////////////////////////////////////////////////////////////////////////////
  6452. // ID3DXAllocateHierarchy ////////////////////////////////////////////////////
  6453. //////////////////////////////////////////////////////////////////////////////
  6454. type
  6455.   {$EXTERNALSYM ID3DXAllocateHierarchy}
  6456.   ID3DXAllocateHierarchy = class
  6457.     // ID3DXAllocateHierarchy
  6458.  
  6459.     //------------------------------------------------------------------------
  6460.     // CreateFrame:
  6461.     // ------------
  6462.     // Requests allocation of a frame object.
  6463.     //
  6464.     // Parameters:
  6465.     //  Name
  6466.     //        Name of the frame to be created
  6467.     //    ppNewFrame
  6468.     //        Returns returns the created frame object
  6469.     //
  6470.     //------------------------------------------------------------------------
  6471.     function CreateFrame(Name: PAnsiChar; out ppNewFrame: PD3DXFrame): HResult; virtual; stdcall; abstract;
  6472.  
  6473.     //------------------------------------------------------------------------
  6474.     // CreateMeshContainer:
  6475.     // --------------------
  6476.     // Requests allocation of a mesh container object.
  6477.     //
  6478.     // Parameters:
  6479.     //  Name
  6480.     //        Name of the mesh
  6481.     //    pMesh
  6482.     //        Pointer to the mesh object if basic polygon data found
  6483.     //    pPMesh
  6484.     //        Pointer to the progressive mesh object if progressive mesh data found
  6485.     //    pPatchMesh
  6486.     //        Pointer to the patch mesh object if patch data found
  6487.     //    pMaterials
  6488.     //        Array of materials used in the mesh
  6489.     //    pEffectInstances
  6490.     //        Array of effect instances used in the mesh
  6491.     //    NumMaterials
  6492.     //        Num elements in the pMaterials array
  6493.     //    pAdjacency
  6494.     //        Adjacency array for the mesh
  6495.     //    pSkinInfo
  6496.     //        Pointer to the skininfo object if the mesh is skinned
  6497.     //    pBoneNames
  6498.     //        Array of names, one for each bone in the skinned mesh.
  6499.     //        The numberof bones can be found from the pSkinMesh object
  6500.     //    pBoneOffsetMatrices
  6501.     //        Array of matrices, one for each bone in the skinned mesh.
  6502.     //
  6503.     //------------------------------------------------------------------------
  6504.     function CreateMeshContainer(Name: PAnsiChar; const pMeshData: TD3DXMeshData;
  6505.         pMaterials: PD3DXMaterial; pEffectInstances: PD3DXEffectInstance;
  6506.         NumMaterials: DWORD; pAdjacency: PDWORD; pSkinInfo: ID3DXSkinInfo;
  6507.         out ppNewMeshContainer: PD3DXMeshContainer): HResult; virtual; stdcall; abstract;
  6508.  
  6509.     //------------------------------------------------------------------------
  6510.     // DestroyFrame:
  6511.     // -------------
  6512.     // Requests de-allocation of a frame object.
  6513.     //
  6514.     // Parameters:
  6515.     //  pFrameToFree
  6516.     //        Pointer to the frame to be de-allocated
  6517.     //
  6518.     //------------------------------------------------------------------------
  6519.     function DestroyFrame(pFrameToFree: PD3DXFrame): HResult; virtual; stdcall; abstract;
  6520.  
  6521.     //------------------------------------------------------------------------
  6522.     // DestroyMeshContainer:
  6523.     // ---------------------
  6524.     // Requests de-allocation of a mesh container object.
  6525.     //
  6526.     // Parameters:
  6527.     //  pMeshContainerToFree
  6528.     //        Pointer to the mesh container object to be de-allocated
  6529.     //
  6530.     //------------------------------------------------------------------------
  6531.     function DestroyMeshContainer(pMeshContainerToFree: PD3DXMeshContainer): HResult; virtual; stdcall; abstract;
  6532.   end;
  6533.  
  6534. //----------------------------------------------------------------------------
  6535. // This interface is implemented by the application to load user data in a .X file
  6536. //   When user data is found, these callbacks will be used to allow the application
  6537. //   to load the data
  6538. //----------------------------------------------------------------------------
  6539. //////////////////////////////////////////////////////////////////////////////
  6540. // ID3DXLoadUserData ////////////////////////////////////////////////////////
  6541. //////////////////////////////////////////////////////////////////////////////
  6542. type
  6543.   {$EXTERNALSYM ID3DXLoadUserData}
  6544.   ID3DXLoadUserData = class
  6545.     function LoadTopLevelData(pXofChildData: IDirectXFileData): HResult; virtual; stdcall; abstract;
  6546.  
  6547.     function LoadFrameChildData(pFrame: PD3DXFrame;
  6548.         pXofChildData: IDirectXFileData): HResult; virtual; stdcall; abstract;
  6549.  
  6550.     function LoadMeshChildData(pMeshContainer: PD3DXMeshContainer;
  6551.         pXofChildData: IDirectXFileData): HResult; virtual; stdcall; abstract;
  6552.   end;
  6553.  
  6554. //----------------------------------------------------------------------------
  6555. // This interface is implemented by the application to save user data in a .X file
  6556. //   The callbacks are called for all data saved.  The user can then add any
  6557. //   child data objects to the object provided to the callback
  6558. //----------------------------------------------------------------------------
  6559. //////////////////////////////////////////////////////////////////////////////
  6560. // ID3DXSaveUserData /////////////////////////////////////////////////////////
  6561. //////////////////////////////////////////////////////////////////////////////
  6562. type
  6563.   {$EXTERNALSYM ID3DXSaveUserData}
  6564.   ID3DXSaveUserData = class
  6565.     function AddFrameChildData(pFrame: PD3DXFrame;
  6566.         pXofSave: IDirectXFileSaveObject; pXofFrameData: IDirectXFileData): HResult; virtual; stdcall; abstract;
  6567.  
  6568.     function AddMeshChildData(pMeshContainer: PD3DXMeshContainer;
  6569.         pXofSave: IDirectXFileSaveObject; pXofMeshData: IDirectXFileData): HResult; virtual; stdcall; abstract;
  6570.  
  6571.     // NOTE: this is called once per Save.  All top level objects should be added using the
  6572.     //    provided interface.  One call adds objects before the frame hierarchy, the other after
  6573.     function AddTopLevelDataObjectsPre(pXofSave: IDirectXFileSaveObject): HResult; virtual; stdcall; abstract;
  6574.     function AddTopLevelDataObjectsPost(pXofSave: IDirectXFileSaveObject): HResult; virtual; stdcall; abstract;
  6575.  
  6576.     // callbacks for the user to register and then save templates to the XFile
  6577.     function RegisterTemplates(pXFileApi: IDirectXFile): HResult; virtual; stdcall; abstract;
  6578.     function SaveTemplates(pXofSave: IDirectXFileSaveObject): HResult; virtual; stdcall; abstract;
  6579.   end;
  6580.  
  6581.  
  6582.  
  6583. //----------------------------------------------------------------------------
  6584. // This interface defines a SRT (scale/rotate/translate) interpolator. This
  6585. // is an abstract interface. ID3DXKeyFrameInterpolator inherits from this.
  6586. // An application can implement this for custom SRT interpolator
  6587. //----------------------------------------------------------------------------
  6588. //////////////////////////////////////////////////////////////////////////////
  6589. // ID3DXInterpolator /////////////////////////////////////////////////////////
  6590. //////////////////////////////////////////////////////////////////////////////
  6591. type
  6592.   PID3DXInterpolator = ^ID3DXInterpolator;
  6593.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXInterpolator);'}
  6594.   {$EXTERNALSYM ID3DXInterpolator}
  6595.   ID3DXInterpolator = interface(IUnknown)
  6596.     ['{ADE2C06D-3747-4b9f-A514-3440B8284980}']
  6597.     // ID3DXInterpolator
  6598.     function GetName: PAnsiChar; stdcall;
  6599.     function GetPeriod: Double; stdcall;
  6600.  
  6601.     //----------------------------------------------------------------------------
  6602.     // GetSRT:
  6603.     // -------
  6604.     // Returns the scale, rotation and translation at a given time
  6605.     //
  6606.     // Parameters:
  6607.     //    Time
  6608.     //        Time at which the interpolator should be queried
  6609.     //    pScale
  6610.     //        Returns the scale vector
  6611.     //    pRotate
  6612.     //        Returns the rotation qaternion
  6613.     //    pTranslate
  6614.     //        Returns the translate vector
  6615.     //
  6616.     //----------------------------------------------------------------------------
  6617.     function GetSRT(Time: Double; pScale: PD3DXVector3; pRotate: PD3DXQuaternion; pTranslate: PD3DXVector3): HResult; stdcall;
  6618.     function GetLastSRT(pScale: PD3DXVector3; pRotate: PD3DXQuaternion; pTranslate: PD3DXVector3): HResult; stdcall;
  6619.   end;
  6620.  
  6621.  
  6622.  
  6623.  
  6624. //----------------------------------------------------------------------------
  6625. // This structure describes a vector key for use in keyframe animation.
  6626. // It specifies a vector Value at a given Time. This is used for scale and
  6627. // translation keys
  6628. //----------------------------------------------------------------------------
  6629. type
  6630.   PD3DXKeyVector3 = ^TD3DXKeyVector3;
  6631.   _D3DXKEY_VECTOR3 = packed record
  6632.     Time: Single;
  6633.     Value: TD3DXVector3;
  6634.   end;
  6635.   {$EXTERNALSYM _D3DXKEY_VECTOR3}
  6636.   D3DXKEY_VECTOR3 = _D3DXKEY_VECTOR3;
  6637.   {$EXTERNALSYM D3DXKEY_VECTOR3}
  6638.   TD3DXKeyVector3 = _D3DXKEY_VECTOR3;
  6639.  
  6640.  
  6641. //----------------------------------------------------------------------------
  6642. // This structure describes a quaternion key for use in keyframe animation.
  6643. // It specifies a quaternion Value at a given Time. This is used for rotation
  6644. // keys
  6645. //----------------------------------------------------------------------------
  6646. type
  6647.   PD3DXKeyQuaternion = ^TD3DXKeyQuaternion;
  6648.   _D3DXKEY_QUATERNION = packed record
  6649.     Time: Single;
  6650.     Value: TD3DXQuaternion;
  6651.   end;
  6652.   {$EXTERNALSYM _D3DXKEY_QUATERNION}
  6653.   D3DXKEY_QUATERNION = _D3DXKEY_QUATERNION;
  6654.   {$EXTERNALSYM D3DXKEY_QUATERNION}
  6655.   TD3DXKeyQuaternion = _D3DXKEY_QUATERNION;
  6656.  
  6657.  
  6658. //----------------------------------------------------------------------------
  6659. // This interface implements an SRT (scale/rotate/translate) interpolator
  6660. // It takes a scattered set of keys and interpolates the transform for any
  6661. // given time
  6662. //----------------------------------------------------------------------------
  6663. //////////////////////////////////////////////////////////////////////////////
  6664. // ID3DXKeyFrameInterpolator /////////////////////////////////////////////////
  6665. //////////////////////////////////////////////////////////////////////////////
  6666. type
  6667.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXKeyFrameInterpolator);'}
  6668.   {$EXTERNALSYM ID3DXKeyFrameInterpolator}
  6669.   ID3DXKeyFrameInterpolator = interface(ID3DXInterpolator)
  6670.     ['{6CAA71F8-0972-4cdb-A55B-43B968997515}']
  6671.     // ID3DXKeyFrameInterpolator
  6672.     function GetNumScaleKeys: LongWord; stdcall;
  6673.     function GetScaleKeys(pKeys: PD3DXKeyVector3): HResult; stdcall;
  6674.  
  6675.     function GetNumRotationKeys: LongWord; stdcall;
  6676.     function GetRotationKeys(pKeys: PD3DXKeyQuaternion): HResult; stdcall;
  6677.  
  6678.     function GetNumTranslationKeys: LongWord; stdcall;
  6679.     function GetTranslationKeys(pKeys: PD3DXKeyVector3): HResult; stdcall;
  6680.  
  6681.     // the value passed to D3DXCreateKeyFrameInterpolator to scale from the times in LPD3DXKEY_VECTOR3 to global/anim time.
  6682.     function GetSourceTicksPerSecond: Double; stdcall;
  6683.   end;
  6684.  
  6685.  
  6686.  
  6687. //----------------------------------------------------------------------------
  6688. // This interface implements an set of interpolators. The set consists of
  6689. // interpolators for many nodes for the same animation.
  6690. //----------------------------------------------------------------------------
  6691. //////////////////////////////////////////////////////////////////////////////
  6692. // ID3DXAnimationSet /////////////////////////////////////////////////////////
  6693. //////////////////////////////////////////////////////////////////////////////
  6694. type
  6695.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXAnimationSet);'}
  6696.   {$EXTERNALSYM ID3DXAnimationSet}
  6697.   ID3DXAnimationSet = interface(IUnknown)
  6698.     ['{54B569AC-0AEF-473e-9704-3FEF317F64AB}']
  6699.     // ID3DXAnimationSet
  6700.     function GetName: PAnsiChar; stdcall;
  6701.     function GetPeriod: Double; stdcall;
  6702.  
  6703.     function GetNumInterpolators: LongWord; stdcall;
  6704.     function GetInterpolatorByIndex(Index: LongWord; out ppInterpolator: ID3DXInterpolator): HResult; stdcall;
  6705.     function GetInterpolatorByName(pName: PAnsiChar; out ppInterpolator: ID3DXInterpolator): HResult; stdcall;
  6706.   end;
  6707.  
  6708. //----------------------------------------------------------------------------
  6709. // This structure describes an animation track. A track is a combination
  6710. //  of an animation set (stored separately) and mixing information.
  6711. //  the mixing information consists of the current position, speed, and blending
  6712. //  weight for the track.  The Flags field also specifies whether the track
  6713. //  is low or high priority.  Tracks with the same priority are blended together
  6714. //  and then the two resulting values are blended using the priority blend factor.
  6715. //----------------------------------------------------------------------------
  6716. type
  6717.   PD3DXTrackDesc = ^TD3DXTrackDesc;
  6718.   _D3DXTRACK_DESC = packed record
  6719.     Flags: DWORD;
  6720.     Weight: Single;
  6721.     Speed: Single;
  6722.     Enable:  BOOL;
  6723.     AnimTime: Double;
  6724.   end;
  6725.   {$EXTERNALSYM _D3DXTRACK_DESC}
  6726.   D3DXTRACK_DESC = _D3DXTRACK_DESC;
  6727.   {$EXTERNALSYM D3DXTRACK_DESC}
  6728.   TD3DXTrackDesc = _D3DXTRACK_DESC;
  6729.  
  6730. //----------------------------------------------------------------------------
  6731. // This enum defines the type of transtion performed on a event that transitions from one value to another
  6732. //----------------------------------------------------------------------------
  6733. type
  6734.   PD3DXTrackFlag = ^TD3DXTrackFlag;
  6735.   _D3DXTRACKFLAG = (
  6736.     D3DXTF_LOWPRIORITY            {= $000},     // This track should be blended with all low priority tracks before mixed with the high priority result
  6737.     D3DXTF_HIGHPRIORITY           {= $001}      // This track should be blended with all high priority tracks before mixed with the low priority result
  6738.   );
  6739.   {$EXTERNALSYM _D3DXTRACKFLAG}
  6740.   D3DXTRACKFLAG = _D3DXTRACKFLAG;
  6741.   {$EXTERNALSYM D3DXTRACKFLAG}
  6742.   TD3DXTrackFlag = _D3DXTRACKFLAG;
  6743.  
  6744.  
  6745. //----------------------------------------------------------------------------
  6746. // This interface implements the main animation functionality. It connects
  6747. // animation sets with the transform frames that are being animated. Allows
  6748. // mixing multiple animations for blended animations or for transistions
  6749. // It adds also has methods to modify blending parameters over time to
  6750. // enable smooth transistions and other effects.
  6751. //----------------------------------------------------------------------------
  6752.  
  6753.  
  6754. //----------------------------------------------------------------------------
  6755. // This enum defines the type of transtion performed on a event that transitions from one value to another
  6756. //----------------------------------------------------------------------------
  6757. type
  6758.   PD3DXTransitionType = ^TD3DXTransitionType;
  6759.   _D3DXTRANSITIONTYPE = (
  6760.     D3DXTRANSITION_LINEAR            {= $000},     // Linear transition from one value to the next
  6761.     D3DXTRANSITION_EASEINEASEOUT     {= $001}      // Ease-In Ease-Out spline transtion from one value to the next
  6762.   );
  6763.   {$EXTERNALSYM _D3DXTRANSITIONTYPE}
  6764.   D3DXTRANSITIONTYPE = _D3DXTRANSITIONTYPE;
  6765.   {$EXTERNALSYM D3DXTRANSITIONTYPE}
  6766.   TD3DXTransitionType = _D3DXTRANSITIONTYPE;
  6767.  
  6768.  
  6769. //////////////////////////////////////////////////////////////////////////////
  6770. // ID3DXAnimationController //////////////////////////////////////////////////
  6771. //////////////////////////////////////////////////////////////////////////////
  6772. type
  6773.   {$HPPEMIT 'DECLARE_DINTERFACE_TYPE(ID3DXAnimationController);'}
  6774.   {$EXTERNALSYM ID3DXAnimationController}
  6775.   ID3DXAnimationController = interface(IUnknown)
  6776.     ['{3A714D34-FF61-421e-909F-639F38356708}']
  6777.   // mixing functionality
  6778.     // register outputs of SetTime
  6779.     function RegisterMatrix(Name: PAnsiChar; const pMatrix: TD3DXMatrix): HResult; stdcall;
  6780.  
  6781.  
  6782.     // AnimationSets
  6783.     function GetNumAnimationSets: LongWord; stdcall;
  6784.     function GetAnimationSet(iAnimationSet: DWORD; out ppAnimSet: ID3DXAnimationSet): HResult; stdcall;
  6785.  
  6786.     function RegisterAnimationSet(pAnimSet: ID3DXAnimationSet): HResult; stdcall;
  6787.     function UnregisterAnimationSet(pAnimSet: ID3DXAnimationSet): HResult; stdcall;
  6788.  
  6789.  
  6790.     // Tracks
  6791.     function GetMaxNumTracks: LongWord; stdcall;
  6792.     function GetTrackDesc(Track: DWORD; out pDesc: TD3DXTrackDesc): HResult; stdcall;
  6793.     function SetTrackDesc(Track: DWORD; const pDesc: TD3DXTrackDesc): HResult; stdcall;
  6794.  
  6795.     function GetTrackAnimationSet(Track: DWORD; out ppAnimSet: ID3DXAnimationSet): HResult; stdcall;
  6796.     function SetTrackAnimationSet(Track: DWORD; pAnimSet: ID3DXAnimationSet): HResult; stdcall;
  6797.  
  6798.     // Individual track field access
  6799.     function SetTrackSpeed(Track: DWORD; Speed: Single): HResult; stdcall;
  6800.     function SetTrackWeight(Track: DWORD; Weight: Single): HResult; stdcall;
  6801.     function SetTrackAnimTime(Track: DWORD; AnimTime: Double): HResult; stdcall;
  6802.     function SetTrackEnable(Track: DWORD; Enable: BOOL): HResult; stdcall;
  6803.  
  6804.     // Time
  6805.     function GetTime: Double; stdcall;
  6806.     function SetTime(Time: Double): HResult; stdcall;
  6807.  
  6808.     function CloneAnimationController(MaxNumMatrices, MaxNumAnimationSets, MaxNumTracks, MaxNumEvents: LongWord; out ppAnimController: ID3DXAnimationController): HResult; stdcall;
  6809.  
  6810.     function GetMaxNumMatrices: LongWord; stdcall;
  6811.     function GetMaxNumEvents: LongWord; stdcall;
  6812.     function GetMaxNumAnimationSets: LongWord; stdcall;
  6813.  
  6814.   // Sequencing abilities
  6815.     function KeyTrackSpeed(Track: DWORD; NewSpeed: Single; StartTime, Duration: Double; Method: DWORD): HResult; stdcall;
  6816.     function KeyTrackWeight(Track: DWORD; NewWeight: Single; StartTime, Duration: Double; Method: DWORD): HResult; stdcall;
  6817.     function KeyTrackAnimTime(Track: DWORD; NewAnimTime, StartTime: Double): HResult; stdcall;
  6818.     function KeyTrackEnable(Track: DWORD; NewEnable: BOOL; StartTime: Double): HResult; stdcall;
  6819.  
  6820.     // this functions sets the blend weight to be used to blend high and low priority tracks together.
  6821.     //  NOTE: this has no effect unless there are active animations on tracks for a given matrix that have both high and low results
  6822.     function GetPriorityBlend: Single; stdcall;
  6823.     function SetPriorityBlend(BlendWeight: Single): HResult; stdcall;
  6824.  
  6825.     function KeyPriorityBlend(NewBlendWeight: Single; StartTime, Duration: Double; Method: DWORD): HResult; stdcall;
  6826.   end;
  6827.  
  6828. type
  6829.   IID_ID3DXInterpolator           = ID3DXInterpolator;
  6830.   {$EXTERNALSYM IID_ID3DXInterpolator}
  6831.   IID_ID3DXKeyFrameInterpolator   = ID3DXKeyFrameInterpolator;
  6832.   {$EXTERNALSYM IID_ID3DXKeyFrameInterpolator}
  6833.   IID_ID3DXAnimationSet           = ID3DXAnimationSet;
  6834.   {$EXTERNALSYM IID_ID3DXAnimationSet}
  6835.   IID_ID3DXAnimationController    = ID3DXAnimationController;
  6836.   {$EXTERNALSYM IID_ID3DXAnimationController}
  6837.  
  6838.  
  6839. //----------------------------------------------------------------------------
  6840. // D3DXLoadMeshHierarchyFromX:
  6841. // ---------------------------
  6842. // Loads the first frame hierarchy in a .X file.
  6843. //
  6844. // Parameters:
  6845. //  Filename
  6846. //      Name of the .X file
  6847. //  MeshOptions
  6848. //      Mesh creation options for meshes in the file (see d3dx9mesh.h)
  6849. //  pD3DDevice
  6850. //      D3D9 device on which meshes in the file are created in
  6851. //  pAlloc
  6852. //      Allocation interface used to allocate nodes of the frame hierarchy
  6853. //  pUserDataLoader
  6854. //      Application provided interface to allow loading of user data
  6855. //  ppFrameHierarchy
  6856. //      Returns root node pointer of the loaded frame hierarchy
  6857. //  ppAnimController
  6858. //      Returns pointer to an animation controller corresponding to animation
  6859. //        in the .X file. This is created with default max tracks and events
  6860. //
  6861. //----------------------------------------------------------------------------
  6862.  
  6863. function D3DXLoadMeshHierarchyFromXA(
  6864.   Filename: PAnsiChar;
  6865.   MeshOptions: DWORD;
  6866.   pD3DDevice: IDirect3DDevice9;
  6867.   pAlloc: ID3DXAllocateHierarchy;
  6868.   pUserDataLoader: ID3DXLoadUserData;
  6869.   out ppFrameHierarchy: PD3DXFrame;
  6870.   out ppAnimController: ID3DXAnimationController): HResult; stdcall; external d3dx9animDLL name 'D3DXLoadMeshHierarchyFromXA';
  6871. {$EXTERNALSYM D3DXLoadMeshHierarchyFromXA}
  6872.  
  6873. function D3DXLoadMeshHierarchyFromXW(
  6874.   Filename: PWideChar;
  6875.   MeshOptions: DWORD;
  6876.   pD3DDevice: IDirect3DDevice9;
  6877.   pAlloc: ID3DXAllocateHierarchy;
  6878.   pUserDataLoader: ID3DXLoadUserData;
  6879.   out ppFrameHierarchy: PD3DXFrame;
  6880.   out ppAnimController: ID3DXAnimationController): HResult; stdcall; external d3dx9animDLL name 'D3DXLoadMeshHierarchyFromXW';
  6881. {$EXTERNALSYM D3DXLoadMeshHierarchyFromXW}
  6882.  
  6883. function D3DXLoadMeshHierarchyFromX(
  6884.   Filename: PChar;
  6885.   MeshOptions: DWORD;
  6886.   pD3DDevice: IDirect3DDevice9;
  6887.   pAlloc: ID3DXAllocateHierarchy;
  6888.   pUserDataLoader: ID3DXLoadUserData;
  6889.   out ppFrameHierarchy: PD3DXFrame;
  6890.   out ppAnimController: ID3DXAnimationController): HResult; stdcall; external d3dx9animDLL name 'D3DXLoadMeshHierarchyFromXA';
  6891. {$EXTERNALSYM D3DXLoadMeshHierarchyFromX}
  6892.  
  6893.  
  6894. function D3DXLoadMeshHierarchyFromXInMemory(
  6895.   Memory: Pointer;
  6896.   SizeOfMemory: DWORD;
  6897.   MeshOptions: DWORD;
  6898.   pD3DDevice: IDirect3DDevice9;
  6899.   pAlloc: ID3DXAllocateHierarchy;
  6900.   pUserDataLoader: ID3DXLoadUserData;
  6901.   out ppFrameHierarchy: PD3DXFrame;
  6902.   out ppAnimController: ID3DXAnimationController): HResult; stdcall; external d3dx9animDLL;
  6903. {$EXTERNALSYM D3DXLoadMeshHierarchyFromXInMemory}
  6904.  
  6905. //----------------------------------------------------------------------------
  6906. // D3DXSaveMeshHierarchyToFile:
  6907. // ---------------------------
  6908. // Creates a .X file and saves the mesh hierarchy and corresponding animations
  6909. // in it
  6910. //
  6911. // Parameters:
  6912. //  Filename
  6913. //      Name of the .X file
  6914. //  XFormat
  6915. //      Format of the .X file (text or binary, compressed or not, etc)
  6916. //  pFrameRoot
  6917. //      Root node of the hierarchy to be saved
  6918. //  pAnimController
  6919. //      The animation mixer whose animation sets are to be stored
  6920. //  pUserDataSaver
  6921. //      Application provided interface to allow adding of user data to
  6922. //        data objects saved to .X file
  6923. //
  6924. //----------------------------------------------------------------------------
  6925.  
  6926. function D3DXSaveMeshHierarchyToFileA(
  6927.   Filename: PAnsiChar;
  6928.   XFormat: TDXFileFormat;
  6929.   pFrameRoot: PD3DXFrame;
  6930.   pAnimMixer: ID3DXAnimationController;
  6931.   pUserDataSaver: ID3DXSaveUserData): HResult; stdcall; external d3dx9animDLL name 'D3DXSaveMeshHierarchyToFileA';
  6932. {$EXTERNALSYM D3DXSaveMeshHierarchyToFileA}
  6933.  
  6934. function D3DXSaveMeshHierarchyToFileW(
  6935.   Filename: PWideChar;
  6936.   XFormat: TDXFileFormat;
  6937.   pFrameRoot: PD3DXFrame;
  6938.   pAnimMixer: ID3DXAnimationController;
  6939.   pUserDataSaver: ID3DXSaveUserData): HResult; stdcall; external d3dx9animDLL name 'D3DXSaveMeshHierarchyToFileW';
  6940. {$EXTERNALSYM D3DXSaveMeshHierarchyToFileW}
  6941.  
  6942. function D3DXSaveMeshHierarchyToFile(
  6943.   Filename: PChar;
  6944.   XFormat: TDXFileFormat;
  6945.   pFrameRoot: PD3DXFrame;
  6946.   pAnimMixer: ID3DXAnimationController;
  6947.   pUserDataSaver: ID3DXSaveUserData): HResult; stdcall; external d3dx9animDLL name 'D3DXSaveMeshHierarchyToFileA';
  6948. {$EXTERNALSYM D3DXSaveMeshHierarchyToFile}
  6949.  
  6950.  
  6951. //----------------------------------------------------------------------------
  6952. // D3DXFrameDestroy:
  6953. // -----------------
  6954. // Destroys the subtree of frames under the root, including the root
  6955. //
  6956. // Parameters:
  6957. //    pFrameRoot
  6958. //        Pointer to the root node
  6959. //  pAlloc
  6960. //      Allocation interface used to de-allocate nodes of the frame hierarchy
  6961. //
  6962. //----------------------------------------------------------------------------
  6963.  
  6964. function D3DXFrameDestroy(
  6965.   pFrameRoot: PD3DXFrame;
  6966.   pAlloc: ID3DXAllocateHierarchy): HResult; stdcall; external d3dx9animDLL;
  6967. {$EXTERNALSYM D3DXFrameDestroy}
  6968.  
  6969. //----------------------------------------------------------------------------
  6970. // D3DXFrameAppendChild:
  6971. // ---------------------
  6972. // Add a child frame to a frame
  6973. //
  6974. // Parameters:
  6975. //    pFrameParent
  6976. //        Pointer to the parent node
  6977. //  pFrameChild
  6978. //      Pointer to the child node
  6979. //
  6980. //----------------------------------------------------------------------------
  6981.  
  6982. function D3DXFrameAppendChild(
  6983.   pFrameParent: PD3DXFrame;
  6984.   pFrameChild: PD3DXFrame): HResult; stdcall; external d3dx9animDLL;
  6985. {$EXTERNALSYM D3DXFrameAppendChild}
  6986.  
  6987. //----------------------------------------------------------------------------
  6988. // D3DXFrameFind:
  6989. // --------------
  6990. // Finds a frame with the given name.  Returns NULL if no frame found.
  6991. //
  6992. // Parameters:
  6993. //    pFrameRoot
  6994. //        Pointer to the root node
  6995. //  Name
  6996. //      Name of frame to find
  6997. //
  6998. //----------------------------------------------------------------------------
  6999.  
  7000. function D3DXFrameFind(
  7001.   pFrameRoot: PD3DXFrame;
  7002.   Name: PAnsiChar): HResult; stdcall; external d3dx9animDLL;
  7003. {$EXTERNALSYM D3DXFrameFind}
  7004.  
  7005. //----------------------------------------------------------------------------
  7006. // D3DXFrameRegisterNamedMatrices:
  7007. // --------------------------
  7008. // Finds all frames that have non-null names and registers each of those frame
  7009. // matrices to the given animation mixer
  7010. //
  7011. // Parameters:
  7012. //    pFrameRoot
  7013. //        Pointer to the root node
  7014. //    pAnimMixer
  7015. //        Pointer to the animation mixer where the matrices are registered
  7016. //
  7017. //----------------------------------------------------------------------------
  7018.  
  7019. function D3DXFrameRegisterNamedMatrices(
  7020.   pFrameRoot: PD3DXFrame;
  7021.   pAnimMixer: ID3DXAnimationController): HResult; stdcall; external d3dx9animDLL;
  7022. {$EXTERNALSYM D3DXFrameRegisterNamedMatrices}
  7023.  
  7024. //----------------------------------------------------------------------------
  7025. // D3DXFrameNumNamedMatrices:
  7026. // --------------------------
  7027. // Counts number of frames in a subtree that have non-null names
  7028. //
  7029. // Parameters:
  7030. //    pFrameRoot
  7031. //        Pointer to the root node of the subtree
  7032. // Return Value:
  7033. //        Count of frames
  7034. //
  7035. //----------------------------------------------------------------------------
  7036.  
  7037. function D3DXFrameNumNamedMatrices(
  7038.   pFrameRoot: PD3DXFrame): HResult; stdcall; external d3dx9animDLL;
  7039. {$EXTERNALSYM D3DXFrameNumNamedMatrices}
  7040.  
  7041. //----------------------------------------------------------------------------
  7042. // D3DXFrameCalculateBoundingSphere:
  7043. // ---------------------------------
  7044. // Computes the bounding sphere of all the meshes in the frame hierarchy
  7045. //
  7046. // Parameters:
  7047. //    pFrameRoot
  7048. //        Pointer to the root node
  7049. //    pObjectCenter
  7050. //        Returns the center of the bounding sphere
  7051. //    pObjectRadius
  7052. //        Returns the radius of the bounding sphere
  7053. //
  7054. //----------------------------------------------------------------------------
  7055.  
  7056. function D3DXFrameCalculateBoundingSphere(
  7057.   pFrameRoot: PD3DXFrame;
  7058.   out pObjectCenter: TD3DXVector3;
  7059.   out pObjectRadius: Single): HResult; stdcall; external d3dx9animDLL;
  7060. {$EXTERNALSYM D3DXFrameCalculateBoundingSphere}
  7061.  
  7062.  
  7063. //----------------------------------------------------------------------------
  7064. // D3DXCreateKeyFrameInterpolator:
  7065. // -------------------------------
  7066. // Creates a SRT key frame interpolator object from the given set of keys
  7067. //
  7068. // Parameters:
  7069. //    ScaleKeys
  7070. //        Array of scale key vectors
  7071. //    NumScaleKeys
  7072. //        Num elements in ScaleKeys array
  7073. //    RotationKeys
  7074. //        Array of rotation key quternions
  7075. //    NumRotationKeys
  7076. //        Num elements in RotationKeys array
  7077. //    TranslateKeys
  7078. //        Array of translation key vectors
  7079. //    NumTranslateKeys
  7080. //        Num elements in TranslateKeys array
  7081. //    ScaleInputTimeBy
  7082. //        All key times are scaled by this factor
  7083. //    ppNewInterpolator
  7084. //        Returns the keyframe interpolator interface
  7085. //
  7086. //----------------------------------------------------------------------------
  7087.  
  7088. function D3DXCreateKeyFrameInterpolator(Name: PAnsiChar;
  7089.   ScaleKeys:    PD3DXKeyVector3;     NumScaleKeys: LongWord;
  7090.   RotationKeys: PD3DXKeyQuaternion;  NumRotationKeys: LongWord;
  7091.   TranslateKeys:    PD3DXKeyVector3; NumTranslateKeys: LongWord;
  7092.   ScaleInputTimeBy: Double; out ppNewInterpolator: ID3DXKeyFrameInterpolator): HResult; stdcall; external d3dx9animDLL;
  7093. {$EXTERNALSYM D3DXCreateKeyFrameInterpolator}
  7094.  
  7095. //----------------------------------------------------------------------------
  7096. // D3DXCreateAnimationSet:
  7097. // -----------------------
  7098. // Creates an animtions set interface given a set of interpolators
  7099. //
  7100. // Parameters:
  7101. //    Name
  7102. //        Name of the animation set
  7103. //    pInterpolators
  7104. //        Array of interpolators
  7105. //    NumInterpolators
  7106. //        Num elements in the pInterpolators array
  7107. //    ppAnimSet
  7108. //        Returns the animation set interface
  7109. //
  7110. //-----------------------------------------------------------------------------
  7111.  
  7112. function D3DXCreateAnimationSet(Name: PAnsiChar;
  7113.   ppInterpolators: PID3DXInterpolator; NumInterpolators: LongWord;
  7114.   out ppAnimSet: ID3DXAnimationSet): HResult; stdcall; external d3dx9animDLL;
  7115. {$EXTERNALSYM D3DXCreateAnimationSet}
  7116.  
  7117. //----------------------------------------------------------------------------
  7118. // D3DXCreateAnimationController:
  7119. // -------------------------
  7120. // Creates an animtion mixer object
  7121. //
  7122. // Parameters:
  7123. //    MaxNumMatrices
  7124. //        The upper limit for the number of matrices that can be animated by the
  7125. //        the object
  7126. //    MaxNumAnimationSets
  7127. //        The upper limit of the number of animation sets that can be played by
  7128. //        the object
  7129. //    MaxNumTracks
  7130. //        The upper limit of the number of animation sets that can be blended at
  7131. //        any time.
  7132. //    MaxNumEvents
  7133. //        The upper limit of the number of outstanding events that can be
  7134. //        scheduled at once.
  7135. //    ppAnimController
  7136. //        Returns the animation controller interface
  7137. //
  7138. //-----------------------------------------------------------------------------
  7139.  
  7140. function D3DXCreateAnimationController(
  7141.   MaxNumMatrices, MaxNumAnimationSets, MaxNumTracks, MaxNumEvents: LongWord;
  7142.   out ppAnimController: ID3DXAnimationController): HResult; stdcall; external d3dx9animDLL;
  7143. {$EXTERNALSYM D3DXCreateAnimationController}
  7144.  
  7145.  
  7146.  
  7147.  
  7148.  
  7149. (*$HPPEMIT '}  /* namespace D3dx9 */' *)
  7150.  
  7151. //***************************************************************************//
  7152. //***************************************************************************//
  7153. //***************************************************************************//
  7154. implementation
  7155. //***************************************************************************//
  7156. //***************************************************************************//
  7157. //***************************************************************************//
  7158.  
  7159.  
  7160.  
  7161.  
  7162.  
  7163.  
  7164. //////////////////////////////////////////////////////////////////////////////
  7165. //
  7166. //  Copyright (C) Microsoft Corporation.  All Rights Reserved.
  7167. //
  7168. //  File:       d3dx8math.h
  7169. //  Content:    D3DX math types and functions
  7170. //
  7171. //////////////////////////////////////////////////////////////////////////////
  7172.  
  7173.  
  7174.  
  7175. //===========================================================================
  7176. //
  7177. // General purpose utilities
  7178. //
  7179. //===========================================================================
  7180.  
  7181. function D3DXToRadian(Degree: Single): Single;
  7182. begin
  7183.   Result:= Degree * (D3DX_PI / 180.0);
  7184. end;
  7185.  
  7186. function D3DXToDegree(Radian: Single): Single;
  7187. begin
  7188.   Result:= Radian * (180.0 / D3DX_PI);
  7189. end;
  7190.  
  7191.  
  7192.  
  7193. //===========================================================================
  7194. //
  7195. // 16 bit floating point numbers
  7196. //
  7197. //===========================================================================
  7198.  
  7199. function D3DXFloat16(value: Single): TD3DXFloat16;
  7200. begin
  7201.   D3DXFloat32To16Array(@Result, @value, 1);
  7202. end;
  7203.  
  7204. function D3DXFloat16Equal(const v1, v2: TD3DXFloat16): Boolean;
  7205. begin
  7206.   Result:= (v1.value = v2.value);
  7207. end;
  7208.  
  7209. function D3DXFloat16ToFloat(value: TD3DXFloat16): Single;
  7210. begin
  7211.   D3DXFloat16To32Array(@Result, @value, 1);
  7212. end;
  7213.  
  7214.  
  7215.  
  7216. //===========================================================================
  7217. //
  7218. // Vectors
  7219. //
  7220. //===========================================================================
  7221.  
  7222. //--------------------------
  7223. // 2D Vector
  7224. //--------------------------
  7225.  
  7226. function D3DXVector2(_x, _y: Single): TD3DXVector2;
  7227. begin
  7228.   Result.x:= _x; Result.y:= _y;
  7229. end;
  7230.  
  7231. function D3DXVector2Equal(const v1, v2: TD3DXVector2): Boolean;
  7232. begin
  7233.   Result:= (v1.x = v2.x) and (v1.y = v2.y);
  7234. end;
  7235.  
  7236.  
  7237. //--------------------------
  7238. // 2D Vector (16 bit)
  7239. //--------------------------
  7240. function D3DXVector2_16F(_x, _y: TD3DXFloat16): TD3DXVector2_16F;
  7241. begin
  7242.   with Result do
  7243.   begin
  7244.     x:= _x;
  7245.     y:= _y;
  7246.   end;
  7247. end;
  7248.  
  7249. function D3DXVector2_16fEqual(const v1, v2: TD3DXVector2_16F): Boolean;
  7250. begin
  7251.   Result:= (DWORD(v1) = DWORD(v2));
  7252. end;
  7253.  
  7254. function D3DXVector2_16fFromVector2(const v: TD3DXVector2): TD3DXVector2_16f;
  7255. begin
  7256.   D3DXFloat32To16Array(@Result.x, @v.x, 2);
  7257. end;
  7258.  
  7259. function D3DXVector2FromVector2_16f(const v: TD3DXVector2_16f): TD3DXVector2;
  7260. begin
  7261.   D3DXFloat16To32Array(@Result.x, @v.x, 2);
  7262. end;
  7263.  
  7264.  
  7265. //--------------------------
  7266. // 3D Vector
  7267. //--------------------------
  7268.  
  7269. function D3DXVector3(_x, _y, _z: Single): TD3DXVector3;
  7270. begin
  7271.   with Result do
  7272.   begin
  7273.     x:= _x; y:= _y; z:=_z;
  7274.   end;
  7275. end;
  7276.  
  7277. function D3DXVector3Equal(const v1, v2: TD3DXVector3): Boolean;
  7278. begin
  7279.   Result:= (v1.x = v2.x) and (v1.y = v2.y) and (v1.z = v2.z);
  7280. end;
  7281.  
  7282.  
  7283. //--------------------------
  7284. // 3D Vector (16 bit)
  7285. //--------------------------
  7286.  
  7287. function D3DXVector3_16F(_x, _y, _z: TD3DXFloat16): TD3DXVector3_16F;
  7288. begin
  7289.   with Result do
  7290.   begin
  7291.     x:= _x; y:= _y; z:= _z;
  7292.   end;
  7293. end;
  7294.  
  7295. function D3DXVector3_16fEqual(const v1, v2: TD3DXVector3_16F): Boolean;
  7296. begin
  7297.   Result:= (PDWORD(@v1.x)^ = PDWORD(@v2.x)^) and
  7298.            (Word  (v1.z)   = Word (v2.z));
  7299. end;
  7300.  
  7301. function D3DXVector3_16fFromVector3(const v: TD3DXVector3): TD3DXVector3_16f;
  7302. begin
  7303.   D3DXFloat32To16Array(@Result.x, @v.x, 3);
  7304. end;
  7305.  
  7306. function D3DXVector3FromVector3_16f(const v: TD3DXVector3_16f): TD3DXVector3;
  7307. begin
  7308.   D3DXFloat16To32Array(@Result.x, @v.x, 3);
  7309. end;
  7310.  
  7311.  
  7312. //--------------------------
  7313. // 4D Vector
  7314. //--------------------------
  7315.  
  7316. function D3DXVector4(_x, _y, _z, _w: Single): TD3DXVector4;
  7317. begin
  7318.   with Result do
  7319.   begin
  7320.     x:= _x; y:= _y; z:= _z; w:= _w;
  7321.   end;
  7322. end;
  7323.  
  7324. function D3DXVector4Equal(const v1, v2: TD3DXVector4): Boolean;
  7325. begin
  7326.   Result:= (v1.x = v2.x) and (v1.y = v2.y) and
  7327.     (v1.z = v2.z) and (v1.w = v2.w);
  7328. end;
  7329.  
  7330.  
  7331. //--------------------------
  7332. // 4D Vector (16 bit)
  7333. //--------------------------
  7334. function D3DXVector4_16F(_x, _y, _z, _w: TD3DXFloat16): TD3DXVector4_16F;
  7335. begin
  7336.   with Result do
  7337.   begin
  7338.     x:= _x; y:= _y; z:= _z; w:= _w;
  7339.   end;
  7340. end;
  7341.  
  7342. function D3DXVector4_16fEqual(const v1, v2: TD3DXVector4_16F): Boolean;
  7343. begin
  7344.   Result:= (PDWORD(@v1.x)^ = PDWORD(@v2.x)^) and
  7345.            (PDWORD(@v1.z)^ = PDWORD(@v2.z)^);
  7346. end;
  7347.  
  7348. function D3DXVector4_16fFromVector4(const v: TD3DXVector4): TD3DXVector4_16f;
  7349. begin
  7350.   D3DXFloat32To16Array(@Result.x, @v.x, 4);
  7351. end;
  7352.  
  7353. function D3DXVector4FromVector4_16f(const v: TD3DXVector4_16f): TD3DXVector4;
  7354. begin
  7355.   D3DXFloat16To32Array(@Result.x, @v.x, 4);
  7356. end;
  7357.  
  7358.  
  7359. //--------------------------
  7360. // 4D Matrix
  7361. //--------------------------
  7362. function D3DXMatrix(
  7363.   _m00, _m01, _m02, _m03,
  7364.   _m10, _m11, _m12, _m13,
  7365.   _m20, _m21, _m22, _m23,
  7366.   _m30, _m31, _m32, _m33: Single): TD3DXMatrix;
  7367. begin
  7368.   with Result do
  7369.   begin
  7370.     m[0,0]:= _m00; m[0,1]:= _m01; m[0,2]:= _m02; m[0,3]:= _m03;
  7371.     m[1,0]:= _m10; m[1,1]:= _m11; m[1,2]:= _m12; m[1,3]:= _m13;
  7372.     m[2,0]:= _m20; m[2,1]:= _m21; m[2,2]:= _m22; m[2,3]:= _m23;
  7373.     m[3,0]:= _m30; m[3,1]:= _m31; m[3,2]:= _m32; m[3,3]:= _m33;
  7374.   end;
  7375. end;
  7376.  
  7377. function D3DXMatrixAdd(out mOut: TD3DXMatrix; const m1, m2: TD3DXMatrix): PD3DXMatrix;
  7378. var
  7379.   pOut, p1, p2: PSingle; x: Integer;
  7380. begin
  7381.   pOut:= @mOut._11; p1:= @m1._11; p2:= @m2._11;
  7382.   for x:= 0 to 15 do
  7383.   begin
  7384.     pOut^:= p1^+p2^;
  7385.     Inc(pOut); Inc(p1); Inc(p2);
  7386.   end;
  7387.   Result:= @mOut;
  7388. end;
  7389.  
  7390. function D3DXMatrixSubtract(out mOut: TD3DXMatrix; const m1, m2: TD3DXMatrix): PD3DXMatrix;
  7391. var
  7392.   pOut, p1, p2: PSingle; x: Integer;
  7393. begin
  7394.   pOut:= @mOut._11; p1:= @m1._11; p2:= @m2._11;
  7395.   for x:= 0 to 15 do
  7396.   begin
  7397.     pOut^:= p1^-p2^;
  7398.     Inc(pOut); Inc(p1); Inc(p2);
  7399.   end;
  7400.   Result:= @mOut;
  7401. end;
  7402.  
  7403. function D3DXMatrixMul(out mOut: TD3DXMatrix; const m: TD3DXMatrix; MulBy: Single): PD3DXMatrix;
  7404. var
  7405.   pOut, p: PSingle; x: Integer;
  7406. begin
  7407.   pOut:= @mOut._11; p:= @m._11;
  7408.   for x:= 0 to 15 do
  7409.   begin
  7410.     pOut^:= p^* MulBy;
  7411.     Inc(pOut); Inc(p);
  7412.   end;
  7413.   Result:= @mOut;
  7414. end;
  7415.  
  7416. function D3DXMatrixEqual(const m1, m2: TD3DXMatrix): Boolean;
  7417. begin
  7418.   Result:= CompareMem(@m1, @m2, SizeOf(TD3DXMatrix));
  7419. end;
  7420.  
  7421. //--------------------------
  7422. // Quaternion
  7423. //--------------------------
  7424. function D3DXQuaternion(_x, _y, _z, _w: Single): TD3DXQuaternion;
  7425. begin
  7426.   with Result do
  7427.   begin
  7428.     x:= _x; y:= _y; z:= _z; w:= _w;
  7429.   end;
  7430. end;
  7431.  
  7432. function D3DXQuaternionAdd(const q1, q2: TD3DXQuaternion): TD3DXQuaternion;
  7433. begin
  7434.   with Result do
  7435.   begin
  7436.     x:= q1.x+q2.x; y:= q1.y+q2.y; z:= q1.z+q2.z; w:= q1.w+q2.w;
  7437.   end;
  7438. end;
  7439.  
  7440. function D3DXQuaternionSubtract(const q1, q2: TD3DXQuaternion): TD3DXQuaternion;
  7441. begin
  7442.   with Result do
  7443.   begin
  7444.     x:= q1.x-q2.x; y:= q1.y-q2.y; z:= q1.z-q2.z; w:= q1.w-q2.w;
  7445.   end;
  7446. end;
  7447.  
  7448. function D3DXQuaternionEqual(const q1, q2: TD3DXQuaternion): Boolean;
  7449. begin
  7450.   Result:= (q1.x = q2.x) and (q1.y = q2.y) and
  7451.     (q1.z = q2.z) and (q1.w = q2.w);
  7452. end;
  7453.  
  7454. function D3DXQuaternionScale(out qOut: TD3DXQuaternion; const q: TD3DXQuaternion;
  7455.   s: Single): PD3DXQuaternion;
  7456. begin
  7457.   with qOut do
  7458.   begin
  7459.     x:= q.x*s; y:= q.y*s; z:= q.z*s; w:= q.w*s;
  7460.   end;
  7461.   Result:= @qOut;
  7462. end;
  7463.  
  7464.  
  7465. //--------------------------
  7466. // Plane
  7467. //--------------------------
  7468.  
  7469. function D3DXPlane(_a, _b, _c, _d: Single): TD3DXPlane;
  7470. begin
  7471.   with Result do
  7472.   begin
  7473.     a:= _a; b:= _b; c:= _c; d:= _d;
  7474.   end;
  7475. end;
  7476.  
  7477. function D3DXPlaneEqual(const p1, p2: TD3DXPlane): Boolean;
  7478. begin
  7479.   Result:=
  7480.     (p1.a = p2.a) and (p1.b = p2.b) and
  7481.     (p1.c = p2.c) and (p1.d = p2.d);
  7482. end;
  7483.  
  7484.  
  7485. //--------------------------
  7486. // Color
  7487. //--------------------------
  7488.  
  7489. function D3DXColor(_r, _g, _b, _a: Single): TD3DXColor;
  7490. begin
  7491.   with Result do
  7492.   begin
  7493.     r:= _r; g:= _g; b:= _b; a:= _a;
  7494.   end;
  7495. end;
  7496.  
  7497. function D3DXColorToDWord(c: TD3DXColor): DWord;
  7498.  
  7499.   function ColorLimit(const x: Single): DWord;
  7500.   begin
  7501.     if x > 1.0 then Result:= 255
  7502.      else if x < 0 then Result:= 0
  7503.       else Result:= Trunc(x * 255.0 + 0.5);
  7504.   end;
  7505. begin
  7506.   Result:= ColorLimit(c.a) shl 24 or ColorLimit(c.r) shl 16
  7507.     or ColorLimit(c.g) shl 8 or ColorLimit(c.b);
  7508. end;
  7509.  
  7510. function D3DXColorFromDWord(c: DWord): TD3DXColor;
  7511. const
  7512.   f: Single = 1/255;
  7513. begin
  7514.   with Result do
  7515.   begin
  7516.     r:= f * Byte(c shr 16);
  7517.     g:= f * Byte(c shr  8);
  7518.     b:= f * Byte(c shr  0);
  7519.     a:= f * Byte(c shr 24);
  7520.   end;
  7521. end;
  7522.  
  7523. function D3DXColorEqual(const c1, c2: TD3DXColor): Boolean;
  7524. begin
  7525.   Result:= (c1.r = c2.r) and (c1.g = c2.g) and (c1.b = c2.b) and (c1.a = c2.a);
  7526. end;
  7527.  
  7528.  
  7529. //===========================================================================
  7530. //
  7531. // D3DX math functions:
  7532. //
  7533. // NOTE:
  7534. //  * All these functions can take the same object as in and out parameters.
  7535. //
  7536. //  * Out parameters are typically also returned as return values, so that
  7537. //    the output of one function may be used as a parameter to another.
  7538. //
  7539. //===========================================================================
  7540.  
  7541. //--------------------------
  7542. // 2D Vector
  7543. //--------------------------
  7544.  
  7545. // "inline"
  7546. function D3DXVec2Length(const v: TD3DXVector2): Single;
  7547. begin
  7548.   with v do Result:= Sqrt(x*x + y*y);
  7549. end;
  7550.  
  7551. function D3DXVec2LengthSq(const v: TD3DXVector2): Single;
  7552. begin
  7553.   with v do Result:= x*x + y*y;
  7554. end;
  7555.  
  7556. function D3DXVec2Dot(const v1, v2: TD3DXVector2): Single;
  7557. begin
  7558.   Result:= v1.x*v2.x + v1.y*v2.y;
  7559. end;
  7560.  
  7561. // Z component of ((x1,y1,0) cross (x2,y2,0))
  7562. function D3DXVec2CCW(const v1, v2: TD3DXVector2): Single;
  7563. begin
  7564.   Result:= v1.x*v2.y - v1.y*v2.x;
  7565. end;
  7566.  
  7567. function D3DXVec2Add(const v1, v2: TD3DXVector2): TD3DXVector2;
  7568. begin
  7569.   Result.x:= v1.x + v2.x;
  7570.   Result.y:= v1.y + v2.y;
  7571. end;
  7572.  
  7573. function D3DXVec2Subtract(const v1, v2: TD3DXVector2): TD3DXVector2;
  7574. begin
  7575.   Result.x:= v1.x - v2.x;
  7576.   Result.y:= v1.y - v2.y;
  7577. end;
  7578.  
  7579. // Minimize each component.  x = min(x1, x2), y = min(y1, y2)
  7580. function D3DXVec2Minimize(out vOut: TD3DXVector2; const v1, v2: TD3DXVEctor2): PD3DXVector2;
  7581. begin
  7582.   if v1.x < v2.x then vOut.x:= v1.x else vOut.y:= v2.x;
  7583.   if v1.y < v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  7584.   Result:= @vOut;
  7585. end;
  7586.  
  7587. // Maximize each component.  x = max(x1, x2), y = max(y1, y2)
  7588. function D3DXVec2Maximize(out vOut: TD3DXVector2; const v1, v2: TD3DXVector2): PD3DXVector2;
  7589. begin
  7590.   if v1.x > v2.x then vOut.x:= v1.x else vOut.y:= v2.x;
  7591.   if v1.y > v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  7592.   Result:= @vOut;
  7593. end;
  7594.  
  7595. function D3DXVec2Scale(out vOut: TD3DXVector2; const v: TD3DXVector2; s: Single): PD3DXVector2;
  7596. begin
  7597.   vOut.x:= v.x*s; vOut.y:= v.y*s;
  7598.   Result:= @vOut;
  7599. end;
  7600.  
  7601. // Linear interpolation. V1 + s(V2-V1)
  7602. function D3DXVec2Lerp(out vOut: TD3DXVector2; const v1, v2: TD3DXVector2; s: Single): PD3DXVector2;
  7603. begin
  7604.   vOut.x:= v1.x + s * (v2.x-v1.x);
  7605.   vOut.y:= v1.y + s * (v2.y-v1.y);
  7606.   Result:= @vOut;
  7607. end;
  7608.  
  7609.  
  7610. //--------------------------
  7611. // 3D Vector
  7612. //--------------------------
  7613. function D3DXVec3Length(const v: TD3DXVector3): Single;
  7614. begin
  7615.   with v do Result:= Sqrt(x*x + y*y + z*z);
  7616. end;
  7617.  
  7618. function D3DXVec3LengthSq(const v: TD3DXVector3): Single;
  7619. begin
  7620.   with v do Result:= x*x + y*y + z*z;
  7621. end;
  7622.  
  7623. function D3DXVec3Dot(const v1, v2: TD3DXVector3): Single;
  7624. begin
  7625.   Result:= v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
  7626. end;
  7627.  
  7628. function D3DXVec3Cross(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  7629. begin
  7630.   vOut.x:= v1.y * v2.z - v1.z * v2.y;
  7631.   vOut.y:= v1.z * v2.x - v1.x * v2.z;
  7632.   vOut.z:= v1.x * v2.y - v1.y * v2.x;
  7633.   Result:= @vOut;
  7634. end;
  7635.  
  7636. function D3DXVec3Add(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  7637. begin
  7638.   with vOut do
  7639.   begin
  7640.     x:= v1.x + v2.x;
  7641.     y:= v1.y + v2.y;
  7642.     z:= v1.z + v2.z;
  7643.   end;
  7644.   Result:= @vOut;
  7645. end;
  7646.  
  7647. function D3DXVec3Subtract(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  7648. begin
  7649.   with vOut do
  7650.   begin
  7651.     x:= v1.x - v2.x;
  7652.     y:= v1.y - v2.y;
  7653.     z:= v1.z - v2.z;
  7654.   end;
  7655.   Result:= @vOut;
  7656. end;
  7657.  
  7658. // Minimize each component.  x = min(x1, x2), y = min(y1, y2)
  7659. function D3DXVec3Minimize(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  7660. begin
  7661.   if v1.x < v2.x then vOut.x:= v1.x else vOut.x:= v2.x;
  7662.   if v1.y < v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  7663.   if v1.z < v2.z then vOut.z:= v1.z else vOut.z:= v2.z;
  7664.   Result:= @vOut;
  7665. end;
  7666.  
  7667. // Maximize each component.  x = max(x1, x2), y = max(y1, y2)
  7668. function D3DXVec3Maximize(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3): PD3DXVector3;
  7669. begin
  7670.   if v1.x > v2.x then vOut.x:= v1.x else vOut.x:= v2.x;
  7671.   if v1.y > v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  7672.   if v1.z > v2.z then vOut.z:= v1.z else vOut.z:= v2.z;
  7673.   Result:= @vOut;
  7674. end;
  7675.  
  7676. function D3DXVec3Scale(out vOut: TD3DXVector3; const v: TD3DXVector3; s: Single): PD3DXVector3;
  7677. begin
  7678.   with vOut do
  7679.   begin
  7680.     x:= v.x * s; y:= v.y * s; z:= v.z * s;
  7681.   end;
  7682.   Result:= @vOut;
  7683. end;
  7684.  
  7685. // Linear interpolation. V1 + s(V2-V1)
  7686. function D3DXVec3Lerp(out vOut: TD3DXVector3; const v1, v2: TD3DXVector3; s: Single): PD3DXVector3;
  7687. begin
  7688.   vOut.x:= v1.x + s * (v2.x-v1.x);
  7689.   vOut.y:= v1.y + s * (v2.y-v1.y);
  7690.   vOut.z:= v1.z + s * (v2.z-v1.z);
  7691.   Result:= @vOut;
  7692. end;
  7693.  
  7694.  
  7695. //--------------------------
  7696. // 4D Vector
  7697. //--------------------------
  7698.  
  7699. function D3DXVec4Length(const v: TD3DXVector4): Single;
  7700. begin
  7701.   with v do Result:= Sqrt(x*x + y*y + z*z + w*w);
  7702. end;
  7703.  
  7704. function D3DXVec4LengthSq(const v: TD3DXVector4): Single;
  7705. begin
  7706.   with v do Result:= x*x + y*y + z*z + w*w
  7707. end;
  7708.  
  7709. function D3DXVec4Dot(const v1, v2: TD3DXVector4): Single;
  7710. begin
  7711.   Result:= v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w;
  7712. end;
  7713.  
  7714. function D3DXVec4Add(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  7715. begin
  7716.   with vOut do
  7717.   begin
  7718.     x:= v1.x + v2.x;
  7719.     y:= v1.y + v2.y;
  7720.     z:= v1.z + v2.z;
  7721.     w:= v1.w + v2.w;
  7722.   end;
  7723.   Result:= @vOut;
  7724. end;
  7725.  
  7726. function D3DXVec4Subtract(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  7727. begin
  7728.   with vOut do
  7729.   begin
  7730.     x:= v1.x - v2.x;
  7731.     y:= v1.y - v2.y;
  7732.     z:= v1.z - v2.z;
  7733.     w:= v1.w - v2.w;
  7734.   end;
  7735.   Result:= @vOut;
  7736. end;
  7737.  
  7738.  
  7739. // Minimize each component.  x = min(x1, x2), y = min(y1, y2)
  7740. function D3DXVec4Minimize(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  7741. begin
  7742.   if v1.x < v2.x then vOut.x:= v1.x else vOut.x:= v2.x;
  7743.   if v1.y < v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  7744.   if v1.z < v2.z then vOut.z:= v1.z else vOut.z:= v2.z;
  7745.   if v1.w < v2.w then vOut.w:= v1.w else vOut.w:= v2.w;
  7746.   Result:= @vOut;
  7747. end;
  7748.  
  7749. // Maximize each component.  x = max(x1, x2), y = max(y1, y2)
  7750. function D3DXVec4Maximize(out vOut: TD3DXVector4; const v1, v2: TD3DXVector4): PD3DXVector4;
  7751. begin
  7752.   if v1.x > v2.x then vOut.x:= v1.x else vOut.x:= v2.x;
  7753.   if v1.y > v2.y then vOut.y:= v1.y else vOut.y:= v2.y;
  7754.   if v1.z > v2.z then vOut.z:= v1.z else vOut.z:= v2.z;
  7755.   if v1.w > v2.w then vOut.w:= v1.w else vOut.w:= v2.w;
  7756.   Result:= @vOut;
  7757. end;
  7758.  
  7759. function D3DXVec4Scale(out vOut: TD3DXVector4; const v: TD3DXVector4; s: Single): PD3DXVector4;
  7760. begin
  7761.   with vOut do
  7762.   begin
  7763.     x:= v.x * s; y:= v.y * s; z:= v.z * s; w:= v.w * s;
  7764.   end;
  7765.   Result:= @vOut;
  7766. end;
  7767.  
  7768. // Linear interpolation. V1 + s(V2-V1)
  7769. function D3DXVec4Lerp(out vOut: TD3DXVector4;
  7770.   const v1, v2: TD3DXVector4; s: Single): PD3DXVector4;
  7771. begin
  7772.   with vOut do
  7773.   begin
  7774.     x:= v1.x + s * (v2.x - v1.x);
  7775.     y:= v1.y + s * (v2.y - v1.y);
  7776.     z:= v1.z + s * (v2.z - v1.z);
  7777.     w:= v1.w + s * (v2.w - v1.w);
  7778.   end;
  7779.   Result:= @vOut;
  7780. end;
  7781.  
  7782. //--------------------------
  7783. // 4D Matrix
  7784. //--------------------------
  7785.  
  7786. // inline
  7787. function D3DXMatrixIdentity(out mOut: TD3DXMatrix): PD3DXMatrix;
  7788. begin
  7789.   FillChar(mOut, SizeOf(mOut), 0);
  7790.   mOut._11:= 1; mOut._22:= 1; mOut._33:= 1; mOut._44:= 1;
  7791.   Result:= @mOut;
  7792. end;
  7793.  
  7794. function D3DXMatrixIsIdentity(const m: TD3DXMatrix): BOOL;
  7795. begin
  7796.   with m do Result:=
  7797.     (_11 = 1) and (_12 = 0) and (_13 = 0) and (_14 = 0) and
  7798.     (_21 = 0) and (_22 = 1) and (_23 = 0) and (_24 = 0) and
  7799.     (_31 = 0) and (_32 = 0) and (_33 = 1) and (_34 = 0) and
  7800.     (_41 = 0) and (_42 = 0) and (_43 = 0) and (_44 = 1);
  7801. end;
  7802.  
  7803.  
  7804. //--------------------------
  7805. // Quaternion
  7806. //--------------------------
  7807.  
  7808. // inline
  7809.  
  7810. function D3DXQuaternionLength(const q: TD3DXQuaternion): Single;
  7811. begin
  7812.   with q do Result:= Sqrt(x*x + y*y + z*z + w*w);
  7813. end;
  7814.  
  7815. // Length squared, or "norm"
  7816. function D3DXQuaternionLengthSq(const q: TD3DXQuaternion): Single;
  7817. begin
  7818.   with q do Result:= x*x + y*y + z*z + w*w;
  7819. end;
  7820.  
  7821. function D3DXQuaternionDot(const q1, q2: TD3DXQuaternion): Single;
  7822. begin
  7823.   Result:= q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w;
  7824. end;
  7825.  
  7826. function D3DXQuaternionIdentity(out qOut: TD3DXQuaternion): PD3DXQuaternion;
  7827. begin
  7828.   with qOut do
  7829.   begin
  7830.     x:= 0; y:= 0; z:= 0; w:= 1.0;
  7831.   end;
  7832.   Result:= @qOut;
  7833. end;
  7834.  
  7835. function D3DXQuaternionIsIdentity(const q: TD3DXQuaternion): BOOL;
  7836. begin
  7837.   with q do Result:= (x = 0) and (y = 0) and (z = 0) and (w = 1);
  7838. end;
  7839.  
  7840. // (-x, -y, -z, w)
  7841. function D3DXQuaternionConjugate(out qOut: TD3DXQuaternion;
  7842.   const q: TD3DXQuaternion): PD3DXQuaternion;
  7843. begin
  7844.   with qOut do
  7845.   begin
  7846.     x:= -q.x; y:= -q.y; z:= -q.z; w:= q.w;
  7847.   end;
  7848.   Result:= @qOut;
  7849. end;
  7850.  
  7851.  
  7852. //--------------------------
  7853. // Plane
  7854. //--------------------------
  7855.  
  7856. // ax + by + cz + dw
  7857. function D3DXPlaneDot(const p: TD3DXPlane; const v: TD3DXVector4): Single;
  7858. begin
  7859.   with p,v do Result:= a*x + b*y + c*z + d*w;
  7860. end;
  7861.  
  7862. // ax + by + cz + d
  7863. function D3DXPlaneDotCoord(const p: TD3DXPlane; const v: TD3DXVector3): Single;
  7864. begin
  7865.   with p,v do Result:= a*x + b*y + c*z + d;
  7866. end;
  7867.  
  7868. // ax + by + cz
  7869. function D3DXPlaneDotNormal(const p: TD3DXPlane; const v: TD3DXVector3): Single;
  7870. begin
  7871.   with p,v do Result:= a*x + b*y + c*z;
  7872. end;
  7873.  
  7874.  
  7875. //--------------------------
  7876. // Color
  7877. //--------------------------
  7878.  
  7879. // inline
  7880.  
  7881. function D3DXColorNegative(out cOut: TD3DXColor; const c: TD3DXColor): PD3DXColor;
  7882. begin
  7883.  with cOut do
  7884.  begin
  7885.    r:= 1.0 - c.r; g:= 1.0 - c.g; b:= 1.0 - c.b;
  7886.    a:= c.a;
  7887.  end;
  7888.  Result:= @cOut;
  7889. end;
  7890.  
  7891. function D3DXColorAdd(out cOut: TD3DXColor; const c1,c2: TD3DXColor): PD3DXColor;
  7892. begin
  7893.   with cOut do
  7894.   begin
  7895.     r:= c1.r + c2.r; g:= c1.g + c2.g; b:= c1.b + c2.b;
  7896.     a:= c1.a + c2.a;
  7897.   end;
  7898.   Result:= @cOut;
  7899. end;
  7900.  
  7901. function D3DXColorSubtract(out cOut: TD3DXColor; const c1,c2: TD3DXColor): PD3DXColor;
  7902. begin
  7903.   with cOut do
  7904.   begin
  7905.     r:= c1.r - c2.r; g:= c1.g - c2.g; b:= c1.b - c2.b;
  7906.     a:= c1.a - c2.a;
  7907.   end;
  7908.   Result:= @cOut;
  7909. end;
  7910.  
  7911. function D3DXColorScale(out cOut: TD3DXColor; const c: TD3DXColor; s: Single): PD3DXColor;
  7912. begin
  7913.   with cOut do
  7914.   begin
  7915.     r:= c.r * s; g:= c.g * s;
  7916.     b:= c.b * s; a:= c.a * s;
  7917.   end;
  7918.   Result:= @cOut;
  7919. end;
  7920.  
  7921. // (r1*r2, g1*g2, b1*b2, a1*a2)
  7922. function D3DXColorModulate(out cOut: TD3DXColor; const c1,c2: TD3DXColor): PD3DXColor;
  7923. begin
  7924.   with cOut do
  7925.   begin
  7926.     r:= c1.r * c2.r; g:= c1.g * c2.g;
  7927.     b:= c1.b * c2.b; a:= c1.a * c2.a;
  7928.   end;
  7929.   Result:= @cOut;
  7930. end;
  7931.  
  7932. // Linear interpolation of r,g,b, and a. C1 + s(C2-C1)
  7933. function D3DXColorLerp(out cOut: TD3DXColor; const c1,c2: TD3DXColor; s: Single): PD3DXColor;
  7934. begin
  7935.   with cOut do
  7936.   begin
  7937.     r:= c1.r + s * (c2.r - c1.r);
  7938.     g:= c1.g + s * (c2.g - c1.g);
  7939.     b:= c1.b + s * (c2.b - c1.b);
  7940.     a:= c1.a + s * (c2.a - c1.a);
  7941.   end;
  7942.   Result:= @cOut;
  7943. end;
  7944.  
  7945.  
  7946.  
  7947.  
  7948.  
  7949. //////////////////////////////////////////////////////////////////////////////
  7950. //
  7951. //  Copyright (c) Microsoft Corporation.  All rights reserved.
  7952. //
  7953. //  File:       d3dx9shader.h
  7954. //  Content:    D3DX Shader APIs
  7955. //
  7956. //////////////////////////////////////////////////////////////////////////////
  7957.  
  7958.  
  7959. //---------------------------------------------------------------------------
  7960. // D3DXTX_VERSION:
  7961. // --------------
  7962. // Version token used to create a procedural texture filler in effects
  7963. // Used by D3DXFill[]TX functions
  7964. //---------------------------------------------------------------------------
  7965. // #define D3DXTX_VERSION(_Major,_Minor) (('T' << 24) | ('X' << 16) | ((_Major) << 8) | (_Minor))
  7966. function D3DXTX_VERSION(_Major, _Minor: Byte): DWORD;
  7967. begin
  7968.   Result := (Ord('T') shl 24) or (Ord('X') shl 16) or (_Major shl 8) or (_Minor);
  7969. end;
  7970.  
  7971. end.
  7972.  
  7973.